/** * Highlights the correct top level admin menu item for post type add screens. * * @access public * @return void */ public function menu_highlight() { global $typenow; $screen = get_current_screen(); if ($screen->id == 'sp_role') { $this->highlight_admin_menu('edit.php?post_type=sp_staff', 'edit-tags.php?taxonomy=sp_role&post_type=sp_staff'); } elseif (is_sp_config_type($typenow)) { $this->highlight_admin_menu('sportspress', 'sportspress-config'); } elseif ($typenow == 'sp_calendar') { $this->highlight_admin_menu('edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar'); } elseif ($typenow == 'sp_table') { $this->highlight_admin_menu('edit.php?post_type=sp_team', 'edit.php?post_type=sp_table'); } elseif ($typenow == 'sp_list') { $this->highlight_admin_menu('edit.php?post_type=sp_player', 'edit.php?post_type=sp_list'); } }
/** * Change messages when a post type is updated. * * @param array $messages * @return array */ public function post_updated_messages($messages) { global $typenow, $post; if (is_sp_config_type($typenow)) { $obj = get_post_type_object($typenow); for ($i = 0; $i <= 10; $i++) { $messages['post'][$i] = __('Settings saved.', 'sportspress') . ' <a href="' . esc_url(admin_url('edit.php?post_type=' . $typenow)) . '">' . __('View All', 'sportspress') . '</a>'; } } elseif (is_sp_post_type($typenow)) { $obj = get_post_type_object($typenow); $messages['post'][1] = __('Changes saved.', 'sportspress') . ' <a href="' . esc_url(get_permalink($post->ID)) . '">' . $obj->labels->view_item . '</a>'; $messages['post'][4] = __('Changes saved.', 'sportspress'); $messages['post'][6] = __('Success!', 'sportspress') . ' <a href="' . esc_url(get_permalink($post->ID)) . '">' . $obj->labels->view_item . '</a>'; $messages['post'][7] = __('Changes saved.', 'sportspress'); $messages['post'][8] = __('Success!', 'sportspress') . ' <a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '">' . sprintf(__('Preview %s', 'sportspress'), $obj->labels->singular_name) . '</a>'; $messages['post'][9] = sprintf(__('Scheduled for: <b>%1$s</b>.', 'sportspress'), date_i18n(__('M j, Y @ G:i', 'sportspress'), strtotime($post->post_date)), esc_url(get_permalink($post->ID))) . ' <a target="_blank" href="' . esc_url(get_permalink($post->ID)) . '">' . sprintf(__('Preview %s', 'sportspress'), $obj->labels->singular_name) . '</a>'; $messages['post'][10] = __('Success!', 'sportspress') . ' <a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '">' . sprintf(__('Preview %s', 'sportspress'), $obj->labels->singular_name) . '</a>'; } return $messages; }
function sportspress_sanitize_title($title) { if (isset($_POST) && array_key_exists('taxonomy', $_POST)) { return $title; } elseif (isset($_POST) && array_key_exists('post_type', $_POST) && is_sp_config_type($_POST['post_type'])) { $key = isset($_POST['sp_key']) ? $_POST['sp_key'] : null; if (!$key) { $key = isset($_POST['sp_default_key']) ? $_POST['sp_default_key'] : null; } if (!$key) { $key = $_POST['post_title']; } $id = sp_array_value($_POST, 'post_ID', 'var'); $title = sp_get_eos_safe_slug($key, $id); } elseif (isset($_POST) && array_key_exists('post_type', $_POST) && $_POST['post_type'] == 'sp_event') { // Auto slug generation if ($_POST['post_title'] == '' && ($_POST['post_name'] == '' || is_int($_POST['post_name']))) { $title = ''; } } return $title; }
public function delete_config_post($post_id) { $post_type = get_post_type($post_id); if (is_sp_config_type($post_type)) { wp_delete_post($post_id, true); } }
/** * Check if we're saving, then trigger an action based on the post type * * @param int $post_id * @param object $post */ public function save_meta_boxes($post_id, $post) { if (empty($post_id) || empty($post)) { return; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (is_int(wp_is_post_revision($post))) { return; } 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 (!apply_filters('sportspress_user_can', current_user_can('edit_post', $post_id), $post_id)) { return; } if (!is_sp_post_type($post->post_type) && !is_sp_config_type($post->post_type)) { return; } do_action('sportspress_process_' . $post->post_type . '_meta', $post_id, $post); }