diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js index dd72f6ed..59658264 100644 --- a/assets/js/admin/sportspress-admin.js +++ b/assets/js/admin/sportspress-admin.js @@ -26,7 +26,9 @@ jQuery(document).ready(function($){ // Auto key placeholder $("#poststuff #title").on("keyup", function() { - $("#sp_key").attr("placeholder", $(this).val().replace(/[^a-z]/gi,"").toLowerCase()); + val = $(this).val().replace(/[^a-z]/gi,"").toLowerCase(); + $("#sp_variable").attr("placeholder", val); + $("#sp_default_variable").val(val); }); // Activate auto key placeholder diff --git a/includes/admin/class-sp-admin-post-types.php b/includes/admin/class-sp-admin-post-types.php index 28236f87..d977e1f4 100644 --- a/includes/admin/class-sp-admin-post-types.php +++ b/includes/admin/class-sp-admin-post-types.php @@ -35,7 +35,7 @@ class SP_Admin_Post_Types { include( 'post-types/class-sp-admin-cpt-performance.php' ); include( 'post-types/class-sp-admin-cpt-column.php' ); include( 'post-types/class-sp-admin-cpt-metric.php' ); - //include( 'post-types/class-sp-admin-cpt-statistic.php' ); + include( 'post-types/class-sp-admin-cpt-statistic.php' ); include( 'post-types/class-sp-admin-cpt-event.php' ); include( 'post-types/class-sp-admin-cpt-calendar.php' ); include( 'post-types/class-sp-admin-cpt-team.php' ); diff --git a/includes/admin/post-types/class-sp-admin-cpt-column.php b/includes/admin/post-types/class-sp-admin-cpt-column.php index 6c52929d..4be71198 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-column.php +++ b/includes/admin/post-types/class-sp-admin-cpt-column.php @@ -41,7 +41,7 @@ class SP_Admin_CPT_Column extends SP_Admin_CPT { $columns = array( 'cb' => '', 'title' => __( 'Label', 'sportspress' ), - 'sp_key' => __( 'Key', 'sportspress' ), + 'sp_variable' => __( 'Variable', 'sportspress' ), 'sp_equation' => __( 'Equation', 'sportspress' ), 'sp_precision' => __( 'Rounding', 'sportspress' ), 'sp_order' => __( 'Sort Order', 'sportspress' ), @@ -55,7 +55,7 @@ class SP_Admin_CPT_Column extends SP_Admin_CPT { */ public function custom_columns( $column, $post_id ) { switch ( $column ): - case 'sp_key': + case 'sp_variable': global $post; echo $post->post_name; break; diff --git a/includes/admin/post-types/class-sp-admin-cpt-metric.php b/includes/admin/post-types/class-sp-admin-cpt-metric.php index 47fb7da4..a97f30b0 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-metric.php +++ b/includes/admin/post-types/class-sp-admin-cpt-metric.php @@ -5,7 +5,7 @@ * @author ThemeBoy * @category Admin * @package SportsPress/Admin/Post Types - * @version 0.7 + * @version 0.8 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -41,8 +41,7 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT { $columns = array( 'cb' => '', 'title' => __( 'Label', 'sportspress' ), - 'sp_key' => __( 'Key', 'sportspress' ), - 'sp_position' => __( 'Positions', 'sportspress' ), + 'sp_variable' => __( 'Variable', 'sportspress' ), ); return $columns; } @@ -53,8 +52,9 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT { */ public function custom_columns( $column, $post_id ) { switch ( $column ): - case 'sp_position': - echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—'; + case 'sp_variable': + global $post; + echo $post->post_name; break; endswitch; } diff --git a/includes/admin/post-types/class-sp-admin-cpt-outcome.php b/includes/admin/post-types/class-sp-admin-cpt-outcome.php index 120b0663..c97cfc3b 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-outcome.php +++ b/includes/admin/post-types/class-sp-admin-cpt-outcome.php @@ -41,7 +41,7 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT { $columns = array( 'cb' => '', 'title' => __( 'Label', 'sportspress' ), - 'sp_key' => __( 'Key', 'sportspress' ), + 'sp_variable' => __( 'Variable', 'sportspress' ), ); return $columns; } @@ -52,7 +52,7 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT { */ public function custom_columns( $column, $post_id ) { switch ( $column ): - case 'sp_key': + case 'sp_variable': global $post; echo $post->post_name; break; diff --git a/includes/admin/post-types/class-sp-admin-cpt-performance.php b/includes/admin/post-types/class-sp-admin-cpt-performance.php index 5099b402..05f5db0f 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-performance.php +++ b/includes/admin/post-types/class-sp-admin-cpt-performance.php @@ -5,7 +5,7 @@ * @author ThemeBoy * @category Admin * @package SportsPress/Admin/Post Types - * @version 0.7 + * @version 0.8 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -41,9 +41,7 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT { $columns = array( 'cb' => '', 'title' => __( 'Label', 'sportspress' ), - 'sp_key' => __( 'Key', 'sportspress' ), - 'sp_position' => __( 'Positions', 'sportspress' ), - 'sp_calculate' => __( 'Calculate', 'sportspress' ), + 'sp_variable' => __( 'Variable', 'sportspress' ), ); return $columns; } @@ -54,16 +52,10 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT { */ public function custom_columns( $column, $post_id ) { switch ( $column ): - case 'sp_key': + case 'sp_variable': global $post; echo $post->post_name; break; - case 'sp_position': - echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—'; - break; - case 'sp_calculate': - echo sp_get_post_calculate( $post_id ); - break; endswitch; } } diff --git a/includes/admin/post-types/class-sp-admin-cpt-result.php b/includes/admin/post-types/class-sp-admin-cpt-result.php index 47c5bcc5..9f3d6cb3 100644 --- a/includes/admin/post-types/class-sp-admin-cpt-result.php +++ b/includes/admin/post-types/class-sp-admin-cpt-result.php @@ -41,7 +41,7 @@ class SP_Admin_CPT_Result extends SP_Admin_CPT { $columns = array( 'cb' => '', 'title' => __( 'Label', 'sportspress' ), - 'sp_key' => __( 'Key', 'sportspress' ), + 'sp_variable' => __( 'Variable', 'sportspress' ), ); return $columns; } @@ -52,7 +52,7 @@ class SP_Admin_CPT_Result extends SP_Admin_CPT { */ public function custom_columns( $column, $post_id ) { switch ( $column ): - case 'sp_key': + case 'sp_variable': global $post; echo $post->post_name; break; diff --git a/includes/admin/post-types/class-sp-admin-cpt-statistic.php b/includes/admin/post-types/class-sp-admin-cpt-statistic.php new file mode 100644 index 00000000..3618365e --- /dev/null +++ b/includes/admin/post-types/class-sp-admin-cpt-statistic.php @@ -0,0 +1,73 @@ +type = 'sp_statistic'; + + // Admin Columns + add_filter( 'manage_edit-sp_statistic_columns', array( $this, 'edit_columns' ) ); + add_action( 'manage_sp_statistic_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 ); + + // Call SP_Admin_CPT constructor + parent::__construct(); + } + + /** + * Change the columns shown in admin. + */ + public function edit_columns( $existing_columns ) { + $columns = array( + 'cb' => '', + 'title' => __( 'Label', 'sportspress' ), + 'sp_variable' => __( 'Variable', 'sportspress' ), + 'sp_equation' => __( 'Equation', 'sportspress' ), + 'sp_precision' => __( 'Rounding', 'sportspress' ), + ); + return $columns; + } + + /** + * Define our custom columns shown in admin. + * @param string $column + */ + public function custom_columns( $column, $post_id ) { + switch ( $column ): + case 'sp_variable': + global $post; + echo $post->post_name; + break; + case 'sp_equation': + echo sp_get_post_equation( $post_id ); + break; + case 'sp_precision': + echo sp_get_post_precision( $post_id ); + break; + endswitch; + } +} + +endif; + +return new SP_Admin_CPT_Statistic(); diff --git a/includes/admin/post-types/class-sp-admin-meta-boxes.php b/includes/admin/post-types/class-sp-admin-meta-boxes.php index af779608..c9bc5604 100644 --- a/includes/admin/post-types/class-sp-admin-meta-boxes.php +++ b/includes/admin/post-types/class-sp-admin-meta-boxes.php @@ -38,6 +38,9 @@ class SP_Admin_Meta_Boxes { // Save Performance Meta Boxes add_action( 'sportspress_process_sp_performance_meta', 'SP_Meta_Box_Performance_Details::save', 10, 2 ); + // Save Statistic Meta Boxes + add_action( 'sportspress_process_sp_statistic_meta', 'SP_Meta_Box_Statistic_Details::save', 10, 2 ); + // Save Column Meta Boxes add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Details::save', 10, 2 ); @@ -95,6 +98,9 @@ class SP_Admin_Meta_Boxes { // Performance add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Performance_Details::output', 'sp_performance', 'normal', 'high' ); + // Metrics + add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Statistic_Details::output', 'sp_statistic', 'normal', 'high' ); + // Events add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Event_Shortcode::output', 'sp_event', 'side', 'default' ); add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'SP_Meta_Box_Event_Format::output', 'sp_event', 'side', 'default' ); @@ -200,7 +206,7 @@ class SP_Admin_Meta_Boxes { if ( is_int( wp_is_post_autosave( $post ) ) ) return; if ( empty( $_POST['sportspress_meta_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_meta_nonce'], 'sportspress_save_data' ) ) return; if ( ! current_user_can( 'edit_post', $post_id )) return; - if ( ! in_array( $post->post_type, array( 'sp_result', 'sp_outcome', 'sp_performance', 'sp_column', 'sp_metric', 'sp_statistic', 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ) return; + if ( ! in_array( $post->post_type, array( 'sp_result', 'sp_outcome', 'sp_performance', 'sp_statistic', 'sp_column', 'sp_metric', 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ) return; do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post ); } diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-details.php index 37c058de..487f6561 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-column-details.php @@ -28,15 +28,16 @@ class SP_Meta_Box_Column_Details { // Defaults if ( $precision == '' ) $precision = 0; ?> -

+

- + +

ID, $piece, array( 'team_event', 'result', 'outcome' ) ); + sp_equation_selector( $post->ID, $piece, array( 'team_event', 'outcome', 'result' ) ); endforeach; ?>

diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php index acb80835..763e6424 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-metric-details.php @@ -5,7 +5,7 @@ * @author ThemeBoy * @category Admin * @package SportsPress/Admin/Meta Boxes - * @version 0.7.3 + * @version 0.8 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly @@ -22,9 +22,10 @@ class SP_Meta_Box_Metric_Details { wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' ); $calculate = get_post_meta( $post->ID, 'sp_calculate', true ); ?> -

+

- + +

-

+

- + +

ID, 'sp_calculate', true ); ?> -

+

- -

-

-

- ID, $calculate ); ?> + +

-

+

- + +

ID, 'sp_equation', true ) ); + $precision = get_post_meta( $post->ID, 'sp_precision', true ); + + // Defaults + if ( $precision == '' ) $precision = 0; + ?> +

+

+ + +

+

+

+ ID, $piece, array( 'player_event', 'outcome', 'performance', 'metric' ) ); + endforeach; + ?> +

+

+

+ +

+ ÷', '(', ')', '+', '', '×', '' ), + trim( $equation ) ); else: return '—'; @@ -737,19 +737,19 @@ if ( !function_exists( 'sp_equation_selector' ) ) { $options[ __( 'Events', 'sportspress' ) ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ) ); break; case 'result': - $options[ __( 'Team Results', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_result', array( 'for' => '→', 'against' => '←' ), null, false ); + $options[ __( 'Results', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_result', array( 'for' => '→', 'against' => '←' ), null, false ); break; case 'outcome': - $options[ __( 'Event Outcomes', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_outcome', array() ); - $options[ __( 'Event Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' ); - $options[ __( 'Event Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' ); - $options[ __( 'Event Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' ); - break; - case 'column': - $options[ __( 'Table Columns', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_column' ); + $options[ __( 'Outcomes', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_outcome', array() ); + $options[ __( 'Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' ); + $options[ __( 'Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' ); + $options[ __( 'Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' ); break; case 'performance': - $options[ __( 'Player Performance', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_performance' ); + $options[ __( 'Performance', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_performance' ); + break; + case 'metric': + $options[ __( 'Metric', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_metric' ); break; endswitch; endforeach; @@ -2187,7 +2187,7 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) { unset( $columns[ $key ] ); endif; endforeach; - $labels = array_merge( array( 'name' => SP()->text->string('Team', 'team') ), $columns ); + $labels = array_merge( array( 'name' => SP()->text->string('Team') ), $columns ); $merged[0] = $labels; return $merged; endif; @@ -2373,7 +2373,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) { ); $performances = get_posts( $args ); - $columns = array( 'eventsplayed' => SP()->text->string('Played', 'player') ); + $columns = array( 'eventsplayed' => SP()->text->string('Played') ); foreach ( $performances as $performance ): @@ -2476,7 +2476,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) { unset( $columns[ $key ] ); endif; endforeach; - $labels = array_merge( array( 'name' => SP()->text->string('Player', 'player') ), $columns ); + $labels = array_merge( array( 'name' => SP()->text->string('Player') ), $columns ); $merged[0] = $labels; return $merged; endif; @@ -2639,7 +2639,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) { ); $performances = get_posts( $args ); - $columns = array( 'eventsplayed' => SP()->text->string('Played', 'player') ); + $columns = array( 'eventsplayed' => SP()->text->string('Played') ); foreach ( $performances as $performance ): @@ -2735,7 +2735,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) { if ( $admin ): return array( $columns, $data, $placeholders, $merged ); else: - $labels = array_merge( array( 'name' => SP()->text->string('Player', 'player') ), $columns ); + $labels = array_merge( array( 'name' => SP()->text->string('Player') ), $columns ); $merged[0] = $labels; return $merged; endif; @@ -2841,7 +2841,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) { $performance_labels[ $performance->post_name ] = $performance->post_title; $equations[ $performance->post_name ] = get_post_meta( $performance->ID, 'sp_calculate', true ); endforeach; - $columns = array_merge( array( 'eventsplayed' => SP()->text->string('Played', 'player') ), $performance_labels ); + $columns = array_merge( array( 'eventsplayed' => SP()->text->string('Played') ), $performance_labels ); // Generate array of all season ids and season names $div_ids = array(); @@ -2976,7 +2976,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) { if ( $admin ): return array( $columns, $tempdata, $placeholders, $merged, $seasons_teams ); else: - $labels = array_merge( array( 'name' => SP()->text->string('Season'), 'team' => SP()->text->string('Team', 'player'), 'eventsplayed' => SP()->text->string('Played', 'player') ), $columns ); + $labels = array_merge( array( 'name' => SP()->text->string('Season'), 'team' => SP()->text->string('Team'), 'eventsplayed' => SP()->text->string('Played') ), $columns ); $merged[0] = $labels; return $merged; endif; @@ -3003,7 +3003,7 @@ if ( !function_exists( 'sp_delete_duplicate_post' ) ) { function sp_delete_duplicate_post( &$post ) { global $wpdb; - $key = isset( $post['sp_key'] ) ? $post['sp_key'] : null; + $key = isset( $post['sp_variable'] ) ? $post['sp_variable'] : null; if ( ! $key ) $key = $post['post_title']; $id = sp_array_value( $post, 'post_ID', 'var' ); $title = sp_get_eos_safe_slug( $key, $id ); @@ -5280,48 +5280,37 @@ function sp_get_sport_options() { * @return array */ function sp_get_text_options() { - return apply_filters( 'sportspress_text', array( - 'general' => array( - 'league' => __( 'League', 'sportspress' ), - 'season' => __( 'Season', 'sportspress' ), - ), - 'event' => array( - 'event' => __( 'Event', 'sportspress' ), - 'date' => __( 'Date', 'sportspress' ), - 'time' => __( 'Time', 'sportspress' ), - 'results' => __( 'Team Results', 'sportspress' ), - 'team' => __( 'Team', 'sportspress' ), - 'teams' => __( 'Teams', 'sportspress' ), - 'details' => __( 'Details', 'sportspress' ), - 'venue' => __( 'Venue', 'sportspress' ), - 'player' => __( 'Player', 'sportspress' ), - 'substitutes' => __( 'Substitutes', 'sportspress' ), - 'total' => __( 'Total', 'sportspress' ), - 'article' => __( 'Article', 'sportspress' ), - 'preview' => __( 'Preview', 'sportspress' ), - 'recap' => __( 'Recap', 'sportspress' ), - 'view_all_events' => __( 'View all events', 'sportspress' ), - ), - 'team' => array( - 'team' => __( 'Team', 'sportspress' ), - 'teams' => __( 'Teams', 'sportspress' ), - 'pos' => __( 'Pos', 'sportspress' ), - 'view_full_table' => __( 'View full table', 'sportspress' ), - ), - 'player' => array( - 'player' => __( 'Player', 'sportspress' ), - 'position' => __( 'Position', 'sportspress' ), - 'nationality' => __( 'Nationality', 'sportspress' ), - 'current_team' => __( 'Current Team', 'sportspress' ), - 'past_teams' => __( 'Past Teams', 'sportspress' ), - 'rank' => __( 'Rank', 'sportspress' ), - 'played' => __( 'Played', 'sportspress' ), - 'view_all_players' => __( 'View all players', 'sportspress' ), - ), - 'staff' => array( - 'staff' => __( 'Staff', 'sportspress' ), - ), + $strings = apply_filters( 'sportspress_text', array( + 'article' => __( 'Article', 'sportspress' ), + 'current_team' => __( 'Current Team', 'sportspress' ), + 'date' => __( 'Date', 'sportspress' ), + 'details' => __( 'Details', 'sportspress' ), + 'event' => __( 'Event', 'sportspress' ), + 'league' => __( 'League', 'sportspress' ), + 'nationality' => __( 'Nationality', 'sportspress' ), + 'past_teams' => __( 'Past Teams', 'sportspress' ), + 'played' => __( 'Played', 'sportspress' ), + 'player' => __( 'Player', 'sportspress' ), + 'pos' => __( 'Pos', 'sportspress' ), + 'position' => __( 'Position', 'sportspress' ), + 'preview' => __( 'Preview', 'sportspress' ), + 'rank' => __( 'Rank', 'sportspress' ), + 'recap' => __( 'Recap', 'sportspress' ), + 'results' => __( 'Team Results', 'sportspress' ), + 'season' => __( 'Season', 'sportspress' ), + 'staff' => __( 'Staff', 'sportspress' ), + 'substitutes' => __( 'Substitutes', 'sportspress' ), + 'team' => __( 'Team', 'sportspress' ), + 'teams' => __( 'Teams', 'sportspress' ), + 'time' => __( 'Time', 'sportspress' ), + 'total' => __( 'Total', 'sportspress' ), + 'venue' => __( 'Venue', 'sportspress' ), + 'view_all_events' => __( 'View all events', 'sportspress' ), + 'view_all_players' => __( 'View all players', 'sportspress' ), + 'view_full_table' => __( 'View full table', 'sportspress' ), )); + asort( $strings ); + return $strings; } function sp_is_config_type( $typenow = null ) { diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index e2621bcf..d990402c 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -104,7 +104,7 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) { if ( sp_is_config_type( $typenow ) ): switch ( $untranslated_text ): case 'Slug': - $translated_text = __( 'Key', 'sportspress' ); + $translated_text = __( 'Variable', 'sportspress' ); break; endswitch; endif; @@ -178,11 +178,11 @@ function sportspress_sanitize_title( $title ) { return $title; - elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) ): + elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && sp_is_config_type( $_POST['post_type'] ) ): - $key = isset( $_POST['sp_key'] ) ? $_POST['sp_key'] : null; + $key = isset( $_POST['sp_variable'] ) ? $_POST['sp_variable'] : null; - if ( ! $key ) $key = isset( $_POST['post_name'] ) ? $_POST['post_name'] : null; + if ( ! $key ) $key = isset( $_POST['sp_default_variable'] ) ? $_POST['sp_default_variable'] : null; if ( ! $key ) $key = $_POST['post_title'];