Add Default Nationality option at General Settings.
This commit is contained in:
@@ -24,6 +24,14 @@ class SP_Meta_Box_Player_Details {
|
|||||||
|
|
||||||
$number = get_post_meta( $post->ID, 'sp_number', true );
|
$number = get_post_meta( $post->ID, 'sp_number', true );
|
||||||
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
||||||
|
$default_nationality = get_option( 'sportspress_default_nationality' , false );
|
||||||
|
|
||||||
|
if ( empty( $nationalities ) && $default_nationality ) {
|
||||||
|
if ( $default_nationality != '' ) {
|
||||||
|
$nationalities[] = $default_nationality;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ( $nationalities as $index => $nationality ):
|
foreach ( $nationalities as $index => $nationality ):
|
||||||
if ( 2 == strlen( $nationality ) ):
|
if ( 2 == strlen( $nationality ) ):
|
||||||
$legacy = SP()->countries->legacy;
|
$legacy = SP()->countries->legacy;
|
||||||
|
|||||||
67
modules/sportspress-default-nationality.php
Normal file
67
modules/sportspress-default-nationality.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: SportsPress Default Nationality
|
||||||
|
Plugin URI: http://themeboy.com/
|
||||||
|
Description: Add default nationality option to SportsPress Settings.
|
||||||
|
Author: ThemeBoy
|
||||||
|
Author URI: http://themeboy.com/
|
||||||
|
Version: 2.7
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
if ( ! class_exists( 'SportsPress_Default_Nationality' ) ) :
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main SportsPress Default Nationality Class
|
||||||
|
*
|
||||||
|
* @class SportsPress_Default_Nationality
|
||||||
|
* @version 2.7
|
||||||
|
*/
|
||||||
|
class SportsPress_Default_Nationality {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
// Define constants
|
||||||
|
$this->define_constants();
|
||||||
|
|
||||||
|
add_filter( 'sportspress_general_options', array( $this, 'add_general_options' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define constants.
|
||||||
|
*/
|
||||||
|
private function define_constants() {
|
||||||
|
if ( !defined( 'SP_DEFAULT_NATIONALITY_VERSION' ) )
|
||||||
|
define( 'SP_DEFAULT_NATIONALITY_VERSION', '2.7' );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_DEFAULT_NATIONALITY_URL' ) )
|
||||||
|
define( 'SP_DEFAULT_NATIONALITY_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|
||||||
|
if ( !defined( 'SP_DEFAULT_NATIONALITY_DIR' ) )
|
||||||
|
define( 'SP_DEFAULT_NATIONALITY_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add option to SportsPress General Settings.
|
||||||
|
*/
|
||||||
|
public function add_general_options( $settings ) {
|
||||||
|
$countries[''] = __( '— None —', 'sportspress' );
|
||||||
|
$countries = array_merge ( $countries, SP()->countries->countries );
|
||||||
|
$settings[]=array(
|
||||||
|
'title' => __( 'Default Nationality', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_default_nationality',
|
||||||
|
'default' => '',
|
||||||
|
'type' => 'select',
|
||||||
|
'options' => $countries,
|
||||||
|
);
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
new SportsPress_Default_Nationality();
|
||||||
Reference in New Issue
Block a user