| @@ -24,1721 +24,756 @@ | ||
| 24 | 24 | * |
| 25 | 25 | * @package automattic/jetpack |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | -use Automattic\Jetpack\Assets; | |
| 29 | -use Automattic\Jetpack\Roles; | |
| 28 | +if ( ! class_exists( '\Nova_Restaurant' ) ) { | |
| 30 | 29 | |
| 31 | -/** | |
| 32 | - * Create the new Nova CPT. | |
| 33 | - */ | |
| 34 | -class Nova_Restaurant { | |
| 35 | - const MENU_ITEM_POST_TYPE = 'nova_menu_item'; | |
| 36 | - const MENU_ITEM_LABEL_TAX = 'nova_menu_item_label'; | |
| 37 | - const MENU_TAX = 'nova_menu'; | |
| 38 | - | |
| 39 | 30 | /** |
| 40 | - * Version number used when enqueuing all resources (css and js). | |
| 41 | - * | |
| 42 | - * @var string | |
| 31 | + * Create the new Nova CPT. | |
| 43 | 32 | */ |
| 44 | - public $version = '20210303'; | |
| 33 | + class Nova_Restaurant { | |
| 34 | + const MENU_ITEM_POST_TYPE = 'nova_menu_item'; | |
| 35 | + const MENU_ITEM_LABEL_TAX = 'nova_menu_item_label'; | |
| 36 | + const MENU_TAX = 'nova_menu'; | |
| 45 | 37 | |
| 46 | - /** | |
| 47 | - * Default markup for the menu items. | |
| 48 | - * | |
| 49 | - * @var array | |
| 50 | - */ | |
| 51 | - protected $default_menu_item_loop_markup = array( | |
| 52 | - 'menu_tag' => 'section', | |
| 53 | - 'menu_class' => 'menu-items', | |
| 54 | - 'menu_header_tag' => 'header', | |
| 55 | - 'menu_header_class' => 'menu-group-header', | |
| 56 | - 'menu_title_tag' => 'h1', | |
| 57 | - 'menu_title_class' => 'menu-group-title', | |
| 58 | - 'menu_description_tag' => 'div', | |
| 59 | - 'menu_description_class' => 'menu-group-description', | |
| 60 | - ); | |
| 38 | + /** | |
| 39 | + * Store an instance of the new class | |
| 40 | + * | |
| 41 | + * @var Automattic\Jetpack\Classic_Theme_Helper\Nova_Restaurant | |
| 42 | + */ | |
| 43 | + protected $new_instance; | |
| 61 | 44 | |
| 62 | - /** | |
| 63 | - * Array of markup for the menu items. | |
| 64 | - * | |
| 65 | - * @var array | |
| 66 | - */ | |
| 67 | - protected $menu_item_loop_markup = array(); | |
| 45 | + /** | |
| 46 | + * Version number used when enqueuing all resources (css and js). | |
| 47 | + * | |
| 48 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 49 | + * | |
| 50 | + * @var string | |
| 51 | + */ | |
| 52 | + public $version = '20210303'; | |
| 68 | 53 | |
| 69 | - /** | |
| 70 | - * Last term ID of a loop of menu items. | |
| 71 | - * | |
| 72 | - * @var bool|int | |
| 73 | - */ | |
| 74 | - protected $menu_item_loop_last_term_id = false; | |
| 54 | + /** | |
| 55 | + * Default markup for the menu items. | |
| 56 | + * | |
| 57 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 58 | + * | |
| 59 | + * @var array | |
| 60 | + */ | |
| 61 | + protected $default_menu_item_loop_markup = array( | |
| 62 | + 'menu_tag' => 'section', | |
| 63 | + 'menu_class' => 'menu-items', | |
| 64 | + 'menu_header_tag' => 'header', | |
| 65 | + 'menu_header_class' => 'menu-group-header', | |
| 66 | + 'menu_title_tag' => 'h1', | |
| 67 | + 'menu_title_class' => 'menu-group-title', | |
| 68 | + 'menu_description_tag' => 'div', | |
| 69 | + 'menu_description_class' => 'menu-group-description', | |
| 70 | + ); | |
| 75 | 71 | |
| 76 | - /** | |
| 77 | - * Current term ID of a loop of menu items. | |
| 78 | - * | |
| 79 | - * @var bool|int | |
| 80 | - */ | |
| 81 | - protected $menu_item_loop_current_term = false; | |
| 72 | + /** | |
| 73 | + * Array of markup for the menu items. | |
| 74 | + * | |
| 75 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 76 | + * | |
| 77 | + * @var array | |
| 78 | + */ | |
| 79 | + protected $menu_item_loop_markup = array(); | |
| 82 | 80 | |
| 83 | - /** | |
| 84 | - * Initialize class. | |
| 85 | - * | |
| 86 | - * @param array $menu_item_loop_markup Array of markup for the menu items. | |
| 87 | - * | |
| 88 | - * @return self | |
| 89 | - */ | |
| 90 | - public static function init( $menu_item_loop_markup = array() ) { | |
| 91 | - static $instance = false; | |
| 81 | + /** | |
| 82 | + * Last term ID of a loop of menu items. | |
| 83 | + * | |
| 84 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 85 | + * | |
| 86 | + * @var bool|int | |
| 87 | + */ | |
| 88 | + protected $menu_item_loop_last_term_id = false; | |
| 92 | 89 | |
| 93 | - if ( ! $instance ) { | |
| 94 | - $instance = new Nova_Restaurant(); | |
| 95 | - } | |
| 90 | + /** | |
| 91 | + * Current term ID of a loop of menu items. | |
| 92 | + * | |
| 93 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 94 | + * | |
| 95 | + * @var bool|int | |
| 96 | + */ | |
| 97 | + protected $menu_item_loop_current_term = false; | |
| 96 | 98 | |
| 97 | - if ( $menu_item_loop_markup ) { | |
| 98 | - $instance->menu_item_loop_markup = wp_parse_args( $menu_item_loop_markup, $instance->default_menu_item_loop_markup ); | |
| 99 | + /** | |
| 100 | + * Initialize class. | |
| 101 | + * | |
| 102 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 103 | + * | |
| 104 | + * @param array $menu_item_loop_markup Array of markup for the menu items. | |
| 105 | + * | |
| 106 | + * @return Automattic\Jetpack\Classic_Theme_Helper\Nova_Restaurant | |
| 107 | + */ | |
| 108 | + public static function init( $menu_item_loop_markup = array() ) { | |
| 109 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 110 | + return Automattic\Jetpack\Classic_Theme_Helper\Nova_Restaurant::init( $menu_item_loop_markup ); | |
| 99 | 111 | } |
| 100 | 112 | |
| 101 | - return $instance; | |
| 102 | - } | |
| 103 | - | |
| 104 | - /** | |
| 105 | - * Constructor. | |
| 106 | - * Hook into WordPress to create CPT and utilities if needed. | |
| 107 | - */ | |
| 108 | - public function __construct() { | |
| 109 | - if ( ! $this->site_supports_nova() ) { | |
| 110 | - return; | |
| 113 | + /** | |
| 114 | + * Constructor. | |
| 115 | + * Hook into WordPress to create CPT and utilities if needed. | |
| 116 | + */ | |
| 117 | + public function __construct() { | |
| 118 | + $this->new_instance = new Automattic\Jetpack\Classic_Theme_Helper\Nova_Restaurant(); | |
| 111 | 119 | } |
| 112 | 120 | |
| 113 | - $this->register_taxonomies(); | |
| 114 | - $this->register_post_types(); | |
| 115 | - add_action( 'admin_menu', array( $this, 'add_admin_menus' ) ); | |
| 116 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_nova_styles' ) ); | |
| 117 | - add_action( 'admin_head', array( $this, 'set_custom_font_icon' ) ); | |
| 118 | - | |
| 119 | - // Always sort menu items correctly | |
| 120 | - add_action( 'parse_query', array( $this, 'sort_menu_item_queries_by_menu_order' ) ); | |
| 121 | - add_filter( 'posts_results', array( $this, 'sort_menu_item_queries_by_menu_taxonomy' ), 10, 2 ); | |
| 122 | - | |
| 123 | - add_action( 'wp_insert_post', array( $this, 'add_post_meta' ) ); | |
| 124 | - | |
| 125 | - $this->menu_item_loop_markup = $this->default_menu_item_loop_markup; | |
| 126 | - | |
| 127 | - // Only output our Menu Item Loop Markup on a real blog view. Not feeds, XML-RPC, admin, etc. | |
| 128 | - add_filter( 'template_include', array( $this, 'setup_menu_item_loop_markup__in_filter' ) ); | |
| 129 | - | |
| 130 | - add_filter( 'enter_title_here', array( $this, 'change_default_title' ) ); | |
| 131 | - add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) ); | |
| 132 | - add_filter( 'dashboard_glance_items', array( $this, 'add_to_dashboard' ) ); | |
| 133 | - } | |
| 134 | - | |
| 135 | - /** | |
| 136 | - * Should this Custom Post Type be made available? | |
| 137 | - * | |
| 138 | - * @return bool | |
| 139 | - */ | |
| 140 | - public function site_supports_nova() { | |
| 141 | - // If we're on WordPress.com, and it has the menu site vertical. | |
| 142 | - if ( function_exists( 'site_vertical' ) && 'nova_menu' === site_vertical() ) { | |
| 143 | - return true; | |
| 121 | + /** | |
| 122 | + * Forward all method calls to the Nova_Restaurant class. | |
| 123 | + * | |
| 124 | + * @param string $name The name of the method. | |
| 125 | + * @param array $arguments The arguments to pass to the method. | |
| 126 | + * | |
| 127 | + * @throws Exception If the method is not found. | |
| 128 | + */ | |
| 129 | + public function __call( $name, $arguments ) { | |
| 130 | + if ( method_exists( $this->new_instance, $name ) ) { | |
| 131 | + return call_user_func_array( array( $this->new_instance, $name ), $arguments ); | |
| 132 | + } else { | |
| 133 | + // Handle cases where the method is not found | |
| 134 | + throw new Exception( sprintf( 'Undefined method: %s', esc_html( $name ) ) ); | |
| 135 | + } | |
| 144 | 136 | } |
| 145 | 137 | |
| 146 | - // Else, if the current theme requests it. | |
| 147 | - if ( current_theme_supports( self::MENU_ITEM_POST_TYPE ) ) { | |
| 148 | - return true; | |
| 138 | + /** | |
| 139 | + * Forward all static method calls to the Nova_Restaurant class. | |
| 140 | + * | |
| 141 | + * @param string $name The name of the method. | |
| 142 | + * @param array $arguments The arguments to pass to the method. | |
| 143 | + * | |
| 144 | + * @throws Exception If the method is not found. | |
| 145 | + */ | |
| 146 | + public static function __callStatic( $name, $arguments ) { | |
| 147 | + if ( method_exists( Automattic\Jetpack\Classic_Theme_Helper\Nova_Restaurant::class, $name ) ) { | |
| 148 | + return call_user_func_array( array( Automattic\Jetpack\Classic_Theme_Helper\Nova_Restaurant::class, $name ), $arguments ); | |
| 149 | + } else { | |
| 150 | + // Handle cases where the method is not found | |
| 151 | + throw new Exception( sprintf( 'Undefined static method: %s', esc_html( $name ) ) ); | |
| 152 | + } | |
| 149 | 153 | } |
| 150 | 154 | |
| 151 | - // Otherwise, say no unless something wants to filter us to say yes. | |
| 152 | 155 | /** |
| 153 | - * Allow something else to hook in and enable this CPT. | |
| 156 | + * Should this Custom Post Type be made available? | |
| 154 | 157 | * |
| 155 | - * @module custom-content-types | |
| 158 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 156 | 159 | * |
| 157 | - * @since 2.6.0 | |
| 158 | - * | |
| 159 | - * @param bool false Whether or not to enable this CPT. | |
| 160 | - * @param string $var The slug for this CPT. | |
| 160 | + * @return bool | |
| 161 | 161 | */ |
| 162 | - return (bool) apply_filters( 'jetpack_enable_cpt', false, self::MENU_ITEM_POST_TYPE ); | |
| 163 | - } | |
| 162 | + public function site_supports_nova() { | |
| 163 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 164 | + return $this->new_instance->site_supports_nova(); | |
| 165 | + } | |
| 164 | 166 | |
| 165 | - /* Setup */ | |
| 167 | + /* Setup */ | |
| 166 | 168 | |
| 167 | - /** | |
| 168 | - * Register Taxonomies and Post Type | |
| 169 | - */ | |
| 170 | - public function register_taxonomies() { | |
| 171 | - if ( ! taxonomy_exists( self::MENU_ITEM_LABEL_TAX ) ) { | |
| 172 | - register_taxonomy( | |
| 173 | - self::MENU_ITEM_LABEL_TAX, | |
| 174 | - self::MENU_ITEM_POST_TYPE, | |
| 175 | - array( | |
| 176 | - 'labels' => array( | |
| 177 | - /* translators: this is about a food menu */ | |
| 178 | - 'name' => __( 'Menu Item Labels', 'jetpack' ), | |
| 179 | - /* translators: this is about a food menu */ | |
| 180 | - 'singular_name' => __( 'Menu Item Label', 'jetpack' ), | |
| 181 | - /* translators: this is about a food menu */ | |
| 182 | - 'search_items' => __( 'Search Menu Item Labels', 'jetpack' ), | |
| 183 | - 'popular_items' => __( 'Popular Labels', 'jetpack' ), | |
| 184 | - /* translators: this is about a food menu */ | |
| 185 | - 'all_items' => __( 'All Menu Item Labels', 'jetpack' ), | |
| 186 | - /* translators: this is about a food menu */ | |
| 187 | - 'edit_item' => __( 'Edit Menu Item Label', 'jetpack' ), | |
| 188 | - /* translators: this is about a food menu */ | |
| 189 | - 'view_item' => __( 'View Menu Item Label', 'jetpack' ), | |
| 190 | - /* translators: this is about a food menu */ | |
| 191 | - 'update_item' => __( 'Update Menu Item Label', 'jetpack' ), | |
| 192 | - /* translators: this is about a food menu */ | |
| 193 | - 'add_new_item' => __( 'Add New Menu Item Label', 'jetpack' ), | |
| 194 | - /* translators: this is about a food menu */ | |
| 195 | - 'new_item_name' => __( 'New Menu Item Label Name', 'jetpack' ), | |
| 196 | - 'separate_items_with_commas' => __( 'For example, spicy, favorite, etc. <br /> Separate Labels with commas', 'jetpack' ), | |
| 197 | - 'add_or_remove_items' => __( 'Add or remove Labels', 'jetpack' ), | |
| 198 | - 'choose_from_most_used' => __( 'Choose from the most used Labels', 'jetpack' ), | |
| 199 | - 'items_list_navigation' => __( 'Menu item label list navigation', 'jetpack' ), | |
| 200 | - 'items_list' => __( 'Menu item labels list', 'jetpack' ), | |
| 201 | - ), | |
| 202 | - 'no_tagcloud' => __( 'No Labels found', 'jetpack' ), | |
| 203 | - 'hierarchical' => false, | |
| 204 | - ) | |
| 205 | - ); | |
| 169 | + /** | |
| 170 | + * Register Taxonomies and Post Type | |
| 171 | + * | |
| 172 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 173 | + */ | |
| 174 | + public function register_taxonomies() { | |
| 175 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 176 | + $this->new_instance->register_taxonomies(); | |
| 206 | 177 | } |
| 207 | 178 | |
| 208 | - if ( ! taxonomy_exists( self::MENU_TAX ) ) { | |
| 209 | - register_taxonomy( | |
| 210 | - self::MENU_TAX, | |
| 211 | - self::MENU_ITEM_POST_TYPE, | |
| 212 | - array( | |
| 213 | - 'labels' => array( | |
| 214 | - /* translators: this is about a food menu */ | |
| 215 | - 'name' => __( 'Menu Sections', 'jetpack' ), | |
| 216 | - /* translators: this is about a food menu */ | |
| 217 | - 'singular_name' => __( 'Menu Section', 'jetpack' ), | |
| 218 | - /* translators: this is about a food menu */ | |
| 219 | - 'search_items' => __( 'Search Menu Sections', 'jetpack' ), | |
| 220 | - /* translators: this is about a food menu */ | |
| 221 | - 'all_items' => __( 'All Menu Sections', 'jetpack' ), | |
| 222 | - /* translators: this is about a food menu */ | |
| 223 | - 'parent_item' => __( 'Parent Menu Section', 'jetpack' ), | |
| 224 | - /* translators: this is about a food menu */ | |
| 225 | - 'parent_item_colon' => __( 'Parent Menu Section:', 'jetpack' ), | |
| 226 | - /* translators: this is about a food menu */ | |
| 227 | - 'edit_item' => __( 'Edit Menu Section', 'jetpack' ), | |
| 228 | - /* translators: this is about a food menu */ | |
| 229 | - 'view_item' => __( 'View Menu Section', 'jetpack' ), | |
| 230 | - /* translators: this is about a food menu */ | |
| 231 | - 'update_item' => __( 'Update Menu Section', 'jetpack' ), | |
| 232 | - /* translators: this is about a food menu */ | |
| 233 | - 'add_new_item' => __( 'Add New Menu Section', 'jetpack' ), | |
| 234 | - /* translators: this is about a food menu */ | |
| 235 | - 'new_item_name' => __( 'New Menu Sections Name', 'jetpack' ), | |
| 236 | - 'items_list_navigation' => __( 'Menu section list navigation', 'jetpack' ), | |
| 237 | - 'items_list' => __( 'Menu section list', 'jetpack' ), | |
| 238 | - ), | |
| 239 | - 'rewrite' => array( | |
| 240 | - 'slug' => 'menu', | |
| 241 | - 'with_front' => false, | |
| 242 | - 'hierarchical' => true, | |
| 243 | - ), | |
| 244 | - 'hierarchical' => true, | |
| 245 | - 'show_tagcloud' => false, | |
| 246 | - 'query_var' => 'menu', | |
| 247 | - ) | |
| 248 | - ); | |
| 179 | + /** | |
| 180 | + * Register our Post Type. | |
| 181 | + * | |
| 182 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 183 | + */ | |
| 184 | + public function register_post_types() { | |
| 185 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 186 | + $this->new_instance->register_post_types(); | |
| 249 | 187 | } |
| 250 | - } | |
| 251 | 188 | |
| 252 | - /** | |
| 253 | - * Register our Post Type. | |
| 254 | - */ | |
| 255 | - public function register_post_types() { | |
| 256 | - if ( post_type_exists( self::MENU_ITEM_POST_TYPE ) ) { | |
| 257 | - return; | |
| 189 | + /** | |
| 190 | + * Update messages for the Menu Item admin. | |
| 191 | + * | |
| 192 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 193 | + * | |
| 194 | + * @param array $messages Existing post update messages. | |
| 195 | + * | |
| 196 | + * @return array $messages Updated post update messages. | |
| 197 | + */ | |
| 198 | + public function updated_messages( $messages ) { | |
| 199 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 200 | + return $this->new_instance->updated_messages( $messages ); | |
| 258 | 201 | } |
| 259 | 202 | |
| 260 | - register_post_type( | |
| 261 | - self::MENU_ITEM_POST_TYPE, | |
| 262 | - array( | |
| 263 | - 'description' => __( "Items on your restaurant's menu", 'jetpack' ), | |
| 264 | - | |
| 265 | - 'labels' => array( | |
| 266 | - /* translators: this is about a food menu */ | |
| 267 | - 'name' => __( 'Menu Items', 'jetpack' ), | |
| 268 | - /* translators: this is about a food menu */ | |
| 269 | - 'singular_name' => __( 'Menu Item', 'jetpack' ), | |
| 270 | - /* translators: this is about a food menu */ | |
| 271 | - 'menu_name' => __( 'Food Menus', 'jetpack' ), | |
| 272 | - /* translators: this is about a food menu */ | |
| 273 | - 'all_items' => __( 'Menu Items', 'jetpack' ), | |
| 274 | - /* translators: this is about a food menu */ | |
| 275 | - 'add_new' => __( 'Add One Item', 'jetpack' ), | |
| 276 | - /* translators: this is about a food menu */ | |
| 277 | - 'add_new_item' => __( 'Add Menu Item', 'jetpack' ), | |
| 278 | - /* translators: this is about a food menu */ | |
| 279 | - 'edit_item' => __( 'Edit Menu Item', 'jetpack' ), | |
| 280 | - /* translators: this is about a food menu */ | |
| 281 | - 'new_item' => __( 'New Menu Item', 'jetpack' ), | |
| 282 | - /* translators: this is about a food menu */ | |
| 283 | - 'view_item' => __( 'View Menu Item', 'jetpack' ), | |
| 284 | - /* translators: this is about a food menu */ | |
| 285 | - 'search_items' => __( 'Search Menu Items', 'jetpack' ), | |
| 286 | - /* translators: this is about a food menu */ | |
| 287 | - 'not_found' => __( 'No Menu Items found', 'jetpack' ), | |
| 288 | - /* translators: this is about a food menu */ | |
| 289 | - 'not_found_in_trash' => __( 'No Menu Items found in Trash', 'jetpack' ), | |
| 290 | - 'filter_items_list' => __( 'Filter menu items list', 'jetpack' ), | |
| 291 | - 'items_list_navigation' => __( 'Menu item list navigation', 'jetpack' ), | |
| 292 | - 'items_list' => __( 'Menu items list', 'jetpack' ), | |
| 293 | - ), | |
| 294 | - 'supports' => array( | |
| 295 | - 'title', | |
| 296 | - 'editor', | |
| 297 | - 'thumbnail', | |
| 298 | - 'excerpt', | |
| 299 | - ), | |
| 300 | - 'rewrite' => array( | |
| 301 | - 'slug' => 'item', | |
| 302 | - 'with_front' => false, | |
| 303 | - 'feeds' => false, | |
| 304 | - 'pages' => false, | |
| 305 | - ), | |
| 306 | - 'register_meta_box_cb' => array( $this, 'register_menu_item_meta_boxes' ), | |
| 307 | - | |
| 308 | - 'public' => true, | |
| 309 | - 'show_ui' => true, // set to false to replace with custom UI | |
| 310 | - 'menu_position' => 20, // below Pages | |
| 311 | - 'capability_type' => 'page', | |
| 312 | - 'map_meta_cap' => true, | |
| 313 | - 'has_archive' => false, | |
| 314 | - 'query_var' => 'item', | |
| 315 | - ) | |
| 316 | - ); | |
| 317 | - } | |
| 318 | - | |
| 319 | - /** | |
| 320 | - * Update messages for the Menu Item admin. | |
| 321 | - * | |
| 322 | - * @param array $messages Existing post update messages. | |
| 323 | - * | |
| 324 | - * @return array $messages Updated post update messages. | |
| 325 | - */ | |
| 326 | - public function updated_messages( $messages ) { | |
| 327 | - global $post; | |
| 328 | - | |
| 329 | - $messages[ self::MENU_ITEM_POST_TYPE ] = array( | |
| 330 | - 0 => '', // Unused. Messages start at index 1. | |
| 331 | - 1 => sprintf( | |
| 332 | - /* translators: this is about a food menu. Placeholder is a link to the food menu. */ | |
| 333 | - __( 'Menu item updated. <a href="%s">View item</a>', 'jetpack' ), | |
| 334 | - esc_url( get_permalink( $post->ID ) ) | |
| 335 | - ), | |
| 336 | - 2 => esc_html__( 'Custom field updated.', 'jetpack' ), | |
| 337 | - 3 => esc_html__( 'Custom field deleted.', 'jetpack' ), | |
| 338 | - /* translators: this is about a food menu */ | |
| 339 | - 4 => esc_html__( 'Menu item updated.', 'jetpack' ), | |
| 340 | - 5 => isset( $_GET['revision'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling. | |
| 341 | - ? sprintf( | |
| 342 | - /* translators: %s: date and time of the revision */ | |
| 343 | - esc_html__( 'Menu item restored to revision from %s', 'jetpack' ), | |
| 344 | - wp_post_revision_title( (int) $_GET['revision'], false ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling. | |
| 345 | - ) | |
| 346 | - : false, | |
| 347 | - 6 => sprintf( | |
| 348 | - /* translators: this is about a food menu. Placeholder is a link to the food menu. */ | |
| 349 | - __( 'Menu item published. <a href="%s">View item</a>', 'jetpack' ), | |
| 350 | - esc_url( get_permalink( $post->ID ) ) | |
| 351 | - ), | |
| 352 | - /* translators: this is about a food menu */ | |
| 353 | - 7 => esc_html__( 'Menu item saved.', 'jetpack' ), | |
| 354 | - 8 => sprintf( | |
| 355 | - /* translators: this is about a food menu */ | |
| 356 | - __( 'Menu item submitted. <a target="_blank" href="%s">Preview item</a>', 'jetpack' ), | |
| 357 | - esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) | |
| 358 | - ), | |
| 359 | - 9 => sprintf( | |
| 360 | - /* translators: this is about a food menu. 1. Publish box date format, see https://php.net/date 2. link to the food menu. */ | |
| 361 | - __( 'Menu item scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview item</a>', 'jetpack' ), | |
| 362 | - /* translators: Publish box date format, see https://php.net/date */ | |
| 363 | - date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ), | |
| 364 | - esc_url( get_permalink( $post->ID ) ) | |
| 365 | - ), | |
| 366 | - 10 => sprintf( | |
| 367 | - /* translators: this is about a food menu. Placeholder is a link to the food menu. */ | |
| 368 | - __( 'Menu item draft updated. <a target="_blank" href="%s">Preview item</a>', 'jetpack' ), | |
| 369 | - esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) | |
| 370 | - ), | |
| 371 | - ); | |
| 372 | - | |
| 373 | - return $messages; | |
| 374 | - } | |
| 375 | - | |
| 376 | - /** | |
| 377 | - * Nova styles and scripts. | |
| 378 | - * | |
| 379 | - * @param string $hook Page hook. | |
| 380 | - * | |
| 381 | - * @return void | |
| 382 | - */ | |
| 383 | - public function enqueue_nova_styles( $hook ) { | |
| 384 | - global $post_type; | |
| 385 | - $pages = array( 'edit.php', 'post.php', 'post-new.php' ); | |
| 386 | - | |
| 387 | - if ( in_array( $hook, $pages, true ) && $post_type === self::MENU_ITEM_POST_TYPE ) { | |
| 388 | - wp_enqueue_style( 'nova-style', plugins_url( 'css/nova.css', __FILE__ ), array(), $this->version ); | |
| 203 | + /** | |
| 204 | + * Nova styles and scripts. | |
| 205 | + * | |
| 206 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 207 | + * | |
| 208 | + * @param string $hook Page hook. | |
| 209 | + * | |
| 210 | + * @return void | |
| 211 | + */ | |
| 212 | + public function enqueue_nova_styles( $hook ) { | |
| 213 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 214 | + $this->new_instance->enqueue_nova_styles( $hook ); | |
| 389 | 215 | } |
| 390 | 216 | |
| 391 | - wp_enqueue_style( 'nova-font', plugins_url( 'css/nova-font.css', __FILE__ ), array(), $this->version ); | |
| 392 | - } | |
| 393 | - | |
| 394 | - /** | |
| 395 | - * Change ‘Enter Title Here’ text for the Menu Item. | |
| 396 | - * | |
| 397 | - * @param string $title Default title placeholder text. | |
| 398 | - * | |
| 399 | - * @return string | |
| 400 | - */ | |
| 401 | - public function change_default_title( $title ) { | |
| 402 | - if ( self::MENU_ITEM_POST_TYPE === get_post_type() ) { | |
| 403 | - /* translators: this is about a food menu */ | |
| 404 | - $title = esc_html__( "Enter the menu item's name here", 'jetpack' ); | |
| 217 | + /** | |
| 218 | + * Change ‘Enter Title Here’ text for the Menu Item. | |
| 219 | + * | |
| 220 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 221 | + * | |
| 222 | + * @param string $title Default title placeholder text. | |
| 223 | + * | |
| 224 | + * @return string | |
| 225 | + */ | |
| 226 | + public function change_default_title( $title ) { | |
| 227 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 228 | + return $this->new_instance->change_default_title( $title ); | |
| 405 | 229 | } |
| 406 | 230 | |
| 407 | - return $title; | |
| 408 | - } | |
| 409 | - | |
| 410 | - /** | |
| 411 | - * Add to Dashboard At A Glance | |
| 412 | - * | |
| 413 | - * @return void | |
| 414 | - */ | |
| 415 | - public function add_to_dashboard() { | |
| 416 | - $number_menu_items = wp_count_posts( self::MENU_ITEM_POST_TYPE ); | |
| 417 | - | |
| 418 | - $roles = new Roles(); | |
| 419 | - if ( current_user_can( $roles->translate_role_to_cap( 'administrator' ) ) ) { | |
| 420 | - $number_menu_items_published = sprintf( | |
| 421 | - '<a href="%1$s">%2$s</a>', | |
| 422 | - esc_url( | |
| 423 | - get_admin_url( | |
| 424 | - get_current_blog_id(), | |
| 425 | - 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE | |
| 426 | - ) | |
| 427 | - ), | |
| 428 | - sprintf( | |
| 429 | - /* translators: Placehoder is a number of items. */ | |
| 430 | - _n( | |
| 431 | - '%1$d Food Menu Item', | |
| 432 | - '%1$d Food Menu Items', | |
| 433 | - (int) $number_menu_items->publish, | |
| 434 | - 'jetpack' | |
| 435 | - ), | |
| 436 | - number_format_i18n( $number_menu_items->publish ) | |
| 437 | - ) | |
| 438 | - ); | |
| 439 | - } else { | |
| 440 | - $number_menu_items_published = sprintf( | |
| 441 | - '<span>%1$s</span>', | |
| 442 | - sprintf( | |
| 443 | - /* translators: Placehoder is a number of items. */ | |
| 444 | - _n( | |
| 445 | - '%1$d Food Menu Item', | |
| 446 | - '%1$d Food Menu Items', | |
| 447 | - (int) $number_menu_items->publish, | |
| 448 | - 'jetpack' | |
| 449 | - ), | |
| 450 | - number_format_i18n( $number_menu_items->publish ) | |
| 451 | - ) | |
| 452 | - ); | |
| 231 | + /** | |
| 232 | + * Add to Dashboard At A Glance | |
| 233 | + * | |
| 234 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 235 | + * | |
| 236 | + * @return void | |
| 237 | + */ | |
| 238 | + public function add_to_dashboard() { | |
| 239 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 240 | + $this->new_instance->add_to_dashboard(); | |
| 453 | 241 | } |
| 454 | 242 | |
| 455 | - echo '<li class="nova-menu-count">' . $number_menu_items_published . '</li>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- we escape things above. | |
| 456 | - } | |
| 457 | - | |
| 458 | - /** | |
| 459 | - * If the WP query for our menu items. | |
| 460 | - * | |
| 461 | - * @param WP_Query $query WP Query. | |
| 462 | - * | |
| 463 | - * @return bool | |
| 464 | - */ | |
| 465 | - public function is_menu_item_query( $query ) { | |
| 466 | - if ( | |
| 467 | - ( isset( $query->query_vars['taxonomy'] ) && self::MENU_TAX === $query->query_vars['taxonomy'] ) | |
| 468 | - || | |
| 469 | - ( isset( $query->query_vars['post_type'] ) && self::MENU_ITEM_POST_TYPE === $query->query_vars['post_type'] ) | |
| 470 | - ) { | |
| 471 | - return true; | |
| 243 | + /** | |
| 244 | + * If the WP query for our menu items. | |
| 245 | + * | |
| 246 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 247 | + * | |
| 248 | + * @param WP_Query $query WP Query. | |
| 249 | + * | |
| 250 | + * @return bool | |
| 251 | + */ | |
| 252 | + public function is_menu_item_query( $query ) { | |
| 253 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 254 | + return $this->new_instance->is_menu_item_query( $query ); | |
| 472 | 255 | } |
| 473 | 256 | |
| 474 | - return false; | |
| 475 | - } | |
| 476 | - | |
| 477 | - /** | |
| 478 | - * Custom sort the menu item queries by menu order. | |
| 479 | - * | |
| 480 | - * @param WP_Query $query WP Query. | |
| 481 | - * | |
| 482 | - * @return void | |
| 483 | - */ | |
| 484 | - public function sort_menu_item_queries_by_menu_order( $query ) { | |
| 485 | - if ( ! $this->is_menu_item_query( $query ) ) { | |
| 486 | - return; | |
| 257 | + /** | |
| 258 | + * Custom sort the menu item queries by menu order. | |
| 259 | + * | |
| 260 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 261 | + * | |
| 262 | + * @param WP_Query $query WP Query. | |
| 263 | + * | |
| 264 | + * @return void | |
| 265 | + */ | |
| 266 | + public function sort_menu_item_queries_by_menu_order( $query ) { | |
| 267 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 268 | + $this->new_instance->sort_menu_item_queries_by_menu_order( $query ); | |
| 487 | 269 | } |
| 488 | 270 | |
| 489 | - $query->query_vars['orderby'] = 'menu_order'; | |
| 490 | - $query->query_vars['order'] = 'ASC'; | |
| 491 | - | |
| 492 | - // For now, just turn off paging so we can sort by taxonmy later | |
| 493 | - // If we want paging in the future, we'll need to add the taxonomy sort here (or at least before the DB query is made) | |
| 494 | - $query->query_vars['posts_per_page'] = -1; | |
| 495 | - } | |
| 496 | - | |
| 497 | - /** | |
| 498 | - * Custom sort the menu item queries by menu taxonomies. | |
| 499 | - * | |
| 500 | - * @param WP_Post[] $posts Array of post objects. | |
| 501 | - * @param WP_Query $query The WP_Query instance. | |
| 502 | - * | |
| 503 | - * @return WP_Post[] | |
| 504 | - */ | |
| 505 | - public function sort_menu_item_queries_by_menu_taxonomy( $posts, $query ) { | |
| 506 | - if ( ! $posts ) { | |
| 507 | - return $posts; | |
| 271 | + /** | |
| 272 | + * Custom sort the menu item queries by menu taxonomies. | |
| 273 | + * | |
| 274 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 275 | + * | |
| 276 | + * @param WP_Post[] $posts Array of post objects. | |
| 277 | + * @param WP_Query $query The WP_Query instance. | |
| 278 | + * | |
| 279 | + * @return WP_Post[] | |
| 280 | + */ | |
| 281 | + public function sort_menu_item_queries_by_menu_taxonomy( $posts, $query ) { | |
| 282 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 283 | + return $this->new_instance->sort_menu_item_queries_by_menu_taxonomy( $posts, $query ); | |
| 508 | 284 | } |
| 509 | 285 | |
| 510 | - if ( ! $this->is_menu_item_query( $query ) ) { | |
| 511 | - return $posts; | |
| 286 | + /** | |
| 287 | + * Add new "Add many items" submenu, custom colunmns, and custom bulk actions. | |
| 288 | + * | |
| 289 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 290 | + * | |
| 291 | + * @return void | |
| 292 | + */ | |
| 293 | + public function add_admin_menus() { | |
| 294 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 295 | + $this->new_instance->add_admin_menus(); | |
| 512 | 296 | } |
| 513 | 297 | |
| 514 | - $grouped_by_term = array(); | |
| 515 | - | |
| 516 | - foreach ( $posts as $post ) { | |
| 517 | - $term = $this->get_menu_item_menu_leaf( $post->ID ); | |
| 518 | - if ( ! $term || is_wp_error( $term ) ) { | |
| 519 | - $term_id = 0; | |
| 520 | - } else { | |
| 521 | - $term_id = $term->term_id; | |
| 522 | - } | |
| 523 | - | |
| 524 | - if ( ! isset( $grouped_by_term[ "$term_id" ] ) ) { | |
| 525 | - $grouped_by_term[ "$term_id" ] = array(); | |
| 526 | - } | |
| 527 | - | |
| 528 | - $grouped_by_term[ "$term_id" ][] = $post; | |
| 298 | + /** | |
| 299 | + * Custom Nova Icon CSS | |
| 300 | + * | |
| 301 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 302 | + * | |
| 303 | + * @return void | |
| 304 | + */ | |
| 305 | + public function set_custom_font_icon() { | |
| 306 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 307 | + $this->new_instance->set_custom_font_icon(); | |
| 529 | 308 | } |
| 530 | 309 | |
| 531 | - $term_order = get_option( 'nova_menu_order', array() ); | |
| 532 | - | |
| 533 | - $return = array(); | |
| 534 | - foreach ( $term_order as $term_id ) { | |
| 535 | - if ( isset( $grouped_by_term[ "$term_id" ] ) ) { | |
| 536 | - $return = array_merge( $return, $grouped_by_term[ "$term_id" ] ); | |
| 537 | - unset( $grouped_by_term[ "$term_id" ] ); | |
| 538 | - } | |
| 310 | + /** | |
| 311 | + * Load Nova menu management tools on the CPT admin screen. | |
| 312 | + * | |
| 313 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 314 | + * | |
| 315 | + * @return void | |
| 316 | + */ | |
| 317 | + public function current_screen_load() { | |
| 318 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 319 | + $this->new_instance->current_screen_load(); | |
| 539 | 320 | } |
| 540 | 321 | |
| 541 | - foreach ( $grouped_by_term as $term_id => $posts ) { | |
| 542 | - $return = array_merge( $return, $posts ); | |
| 543 | - } | |
| 322 | + /* Edit Items List */ | |
| 544 | 323 | |
| 545 | - return $return; | |
| 546 | - } | |
| 547 | - | |
| 548 | - /** | |
| 549 | - * Add new "Add many items" submenu, custom colunmns, and custom bulk actions. | |
| 550 | - * | |
| 551 | - * @return void | |
| 552 | - */ | |
| 553 | - public function add_admin_menus() { | |
| 554 | - $hook = add_submenu_page( | |
| 555 | - 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE, | |
| 556 | - __( 'Add Many Items', 'jetpack' ), | |
| 557 | - __( 'Add Many Items', 'jetpack' ), | |
| 558 | - 'edit_pages', | |
| 559 | - 'add_many_nova_items', | |
| 560 | - array( $this, 'add_many_new_items_page' ) | |
| 561 | - ); | |
| 562 | - | |
| 563 | - add_action( "load-$hook", array( $this, 'add_many_new_items_page_load' ) ); | |
| 564 | - | |
| 565 | - add_action( 'current_screen', array( $this, 'current_screen_load' ) ); | |
| 566 | - | |
| 567 | - /* | |
| 568 | - * Adjust 'Add Many Items' submenu position | |
| 569 | - * We're making changes to the menu global, but no other choice unfortunately. | |
| 570 | - * phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited | |
| 324 | + /** | |
| 325 | + * Display a notice in wp-admin after items have been changed. | |
| 326 | + * | |
| 327 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 328 | + * | |
| 329 | + * @return void | |
| 571 | 330 | */ |
| 572 | - if ( isset( $GLOBALS['submenu'][ 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE ] ) ) { | |
| 573 | - $submenu_item = array_pop( $GLOBALS['submenu'][ 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE ] ); | |
| 574 | - $GLOBALS['submenu'][ 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE ][11] = $submenu_item; | |
| 575 | - ksort( $GLOBALS['submenu'][ 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE ] ); | |
| 331 | + public function admin_notices() { | |
| 332 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 333 | + $this->new_instance->admin_notices(); | |
| 576 | 334 | } |
| 577 | - // phpcs:enable WordPress.WP.GlobalVariablesOverride.Prohibited | |
| 578 | 335 | |
| 579 | - $this->setup_menu_item_columns(); | |
| 580 | - | |
| 581 | - wp_register_script( | |
| 582 | - 'nova-menu-checkboxes', | |
| 583 | - Assets::get_file_url_for_environment( | |
| 584 | - '_inc/build/custom-post-types/js/menu-checkboxes.min.js', | |
| 585 | - 'modules/custom-post-types/js/menu-checkboxes.js' | |
| 586 | - ), | |
| 587 | - array( 'jquery' ), | |
| 588 | - $this->version, | |
| 589 | - true | |
| 590 | - ); | |
| 591 | - } | |
| 592 | - | |
| 593 | - /** | |
| 594 | - * Custom Nova Icon CSS | |
| 595 | - * | |
| 596 | - * @return void | |
| 597 | - */ | |
| 598 | - public function set_custom_font_icon() { | |
| 599 | - ?> | |
| 600 | - <style type="text/css"> | |
| 601 | - #menu-posts-nova_menu_item .wp-menu-image:before { | |
| 602 | - font-family: 'nova-font' !important; | |
| 603 | - content: '\e603' !important; | |
| 604 | - } | |
| 605 | - </style> | |
| 606 | - <?php | |
| 607 | - } | |
| 608 | - | |
| 609 | - /** | |
| 610 | - * Load Nova menu management tools on the CPT admin screen. | |
| 611 | - * | |
| 612 | - * @return void | |
| 613 | - */ | |
| 614 | - public function current_screen_load() { | |
| 615 | - $screen = get_current_screen(); | |
| 616 | - if ( 'edit-nova_menu_item' !== $screen->id ) { | |
| 617 | - return; | |
| 336 | + /** | |
| 337 | + * Do not allow sorting by title. | |
| 338 | + * | |
| 339 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 340 | + * | |
| 341 | + * @param array $columns An array of sortable columns. | |
| 342 | + * | |
| 343 | + * @return array $columns. | |
| 344 | + */ | |
| 345 | + public function no_title_sorting( $columns ) { | |
| 346 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 347 | + return $this->new_instance->no_title_sorting( $columns ); | |
| 618 | 348 | } |
| 619 | 349 | |
| 620 | - $this->edit_menu_items_page_load(); | |
| 621 | - add_filter( 'admin_notices', array( $this, 'admin_notices' ) ); | |
| 622 | - } | |
| 623 | - | |
| 624 | - /* Edit Items List */ | |
| 625 | - | |
| 626 | - /** | |
| 627 | - * Display a notice in wp-admin after items have been changed. | |
| 628 | - * | |
| 629 | - * @return void | |
| 630 | - */ | |
| 631 | - public function admin_notices() { | |
| 632 | - if ( isset( $_GET['nova_reordered'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- this is only displaying a message with no dynamic values. | |
| 633 | - printf( | |
| 634 | - '<div class="updated"><p>%s</p></div>', | |
| 635 | - /* translators: this is about a food menu */ | |
| 636 | - esc_html__( 'Menu Items re-ordered.', 'jetpack' ) | |
| 637 | - ); | |
| 350 | + /** | |
| 351 | + * Set up custom columns for our Nova menu. | |
| 352 | + * | |
| 353 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 354 | + * | |
| 355 | + * @return void | |
| 356 | + */ | |
| 357 | + public function setup_menu_item_columns() { | |
| 358 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 359 | + $this->new_instance->setup_menu_item_columns(); | |
| 638 | 360 | } |
| 639 | - } | |
| 640 | 361 | |
| 641 | - /** | |
| 642 | - * Do not allow sorting by title. | |
| 643 | - * | |
| 644 | - * @param array $columns An array of sortable columns. | |
| 645 | - * | |
| 646 | - * @return array $columns. | |
| 647 | - */ | |
| 648 | - public function no_title_sorting( $columns ) { | |
| 649 | - if ( isset( $columns['title'] ) ) { | |
| 650 | - unset( $columns['title'] ); | |
| 362 | + /** | |
| 363 | + * Add custom columns to the Nova menu item list. | |
| 364 | + * | |
| 365 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 366 | + * | |
| 367 | + * @param array $columns An array of columns. | |
| 368 | + * | |
| 369 | + * @return array $columns. | |
| 370 | + */ | |
| 371 | + public function menu_item_columns( $columns ) { | |
| 372 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 373 | + return $this->new_instance->menu_item_columns( $columns ); | |
| 651 | 374 | } |
| 652 | - return $columns; | |
| 653 | - } | |
| 654 | 375 | |
| 655 | - /** | |
| 656 | - * Set up custom columns for our Nova menu. | |
| 657 | - * | |
| 658 | - * @return void | |
| 659 | - */ | |
| 660 | - public function setup_menu_item_columns() { | |
| 661 | - add_filter( sprintf( 'manage_edit-%s_sortable_columns', self::MENU_ITEM_POST_TYPE ), array( $this, 'no_title_sorting' ) ); | |
| 662 | - add_filter( sprintf( 'manage_%s_posts_columns', self::MENU_ITEM_POST_TYPE ), array( $this, 'menu_item_columns' ) ); | |
| 663 | - | |
| 664 | - add_action( sprintf( 'manage_%s_posts_custom_column', self::MENU_ITEM_POST_TYPE ), array( $this, 'menu_item_column_callback' ), 10, 2 ); | |
| 665 | - } | |
| 666 | - | |
| 667 | - /** | |
| 668 | - * Add custom columns to the Nova menu item list. | |
| 669 | - * | |
| 670 | - * @param array $columns An array of columns. | |
| 671 | - * | |
| 672 | - * @return array $columns. | |
| 673 | - */ | |
| 674 | - public function menu_item_columns( $columns ) { | |
| 675 | - unset( $columns['date'], $columns['likes'] ); | |
| 676 | - | |
| 677 | - $columns['thumbnail'] = __( 'Thumbnail', 'jetpack' ); | |
| 678 | - $columns['labels'] = __( 'Labels', 'jetpack' ); | |
| 679 | - $columns['price'] = __( 'Price', 'jetpack' ); | |
| 680 | - $columns['order'] = __( 'Order', 'jetpack' ); | |
| 681 | - | |
| 682 | - return $columns; | |
| 683 | - } | |
| 684 | - | |
| 685 | - /** | |
| 686 | - * Display custom data in each new custom column we created. | |
| 687 | - * | |
| 688 | - * @param string $column The name of the column to display. | |
| 689 | - * @param int $post_id The current post ID. | |
| 690 | - * | |
| 691 | - * @return void | |
| 692 | - */ | |
| 693 | - public function menu_item_column_callback( $column, $post_id ) { | |
| 694 | - $screen = get_current_screen(); | |
| 695 | - | |
| 696 | - switch ( $column ) { | |
| 697 | - case 'thumbnail': | |
| 698 | - echo get_the_post_thumbnail( $post_id, array( 50, 50 ) ); | |
| 699 | - break; | |
| 700 | - case 'labels': | |
| 701 | - $this->list_admin_labels( $post_id ); | |
| 702 | - break; | |
| 703 | - case 'price': | |
| 704 | - $this->display_price( $post_id ); | |
| 705 | - break; | |
| 706 | - case 'order': | |
| 707 | - $url = admin_url( $screen->parent_file ); | |
| 708 | - | |
| 709 | - $up_url = add_query_arg( | |
| 710 | - array( | |
| 711 | - 'action' => 'move-item-up', | |
| 712 | - 'post_id' => (int) $post_id, | |
| 713 | - ), | |
| 714 | - wp_nonce_url( $url, 'nova_move_item_up_' . $post_id ) | |
| 715 | - ); | |
| 716 | - | |
| 717 | - $down_url = add_query_arg( | |
| 718 | - array( | |
| 719 | - 'action' => 'move-item-down', | |
| 720 | - 'post_id' => (int) $post_id, | |
| 721 | - ), | |
| 722 | - wp_nonce_url( $url, 'nova_move_item_down_' . $post_id ) | |
| 723 | - ); | |
| 724 | - $menu_item = get_post( $post_id ); | |
| 725 | - $this->get_menu_by_post_id( $post_id ); | |
| 726 | - $term_id = $this->get_menu_by_post_id( $post_id ); | |
| 727 | - if ( $term_id ) { | |
| 728 | - $term_id = $term_id->term_id; | |
| 729 | - } | |
| 730 | - ?> | |
| 731 | - <input type="hidden" class="menu-order-value" name="nova_order[<?php echo (int) $post_id; ?>]" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" /> | |
| 732 | - <input type="hidden" class='nova-menu-term' name="nova_menu_term[<?php echo (int) $post_id; ?>]" value="<?php echo esc_attr( $term_id ); ?>"> | |
| 733 | - | |
| 734 | - <span class="hide-if-js"> | |
| 735 | - — <a class="nova-move-item-up" data-post-id="<?php echo (int) $post_id; ?>" href="<?php echo esc_url( $up_url ); ?>">up</a> | |
| 736 | - <br /> | |
| 737 | - — <a class="nova-move-item-down" data-post-id="<?php echo (int) $post_id; ?>" href="<?php echo esc_url( $down_url ); ?>">down</a> | |
| 738 | - </span> | |
| 739 | - <?php | |
| 740 | - break; | |
| 376 | + /** | |
| 377 | + * Display custom data in each new custom column we created. | |
| 378 | + * | |
| 379 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 380 | + * | |
| 381 | + * @param string $column The name of the column to display. | |
| 382 | + * @param int $post_id The current post ID. | |
| 383 | + * | |
| 384 | + * @return void | |
| 385 | + */ | |
| 386 | + public function menu_item_column_callback( $column, $post_id ) { | |
| 387 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 388 | + $this->new_instance->menu_item_column_callback( $column, $post_id ); | |
| 741 | 389 | } |
| 742 | - } | |
| 743 | 390 | |
| 744 | - /** | |
| 745 | - * Get menu item by post ID. | |
| 746 | - * | |
| 747 | - * @param int $post_id Post ID. | |
| 748 | - * | |
| 749 | - * @return bool|WP_Term | |
| 750 | - */ | |
| 751 | - public function get_menu_by_post_id( $post_id = null ) { | |
| 752 | - if ( ! $post_id ) { | |
| 753 | - return false; | |
| 391 | + /** | |
| 392 | + * Get menu item by post ID. | |
| 393 | + * | |
| 394 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 395 | + * | |
| 396 | + * @param int $post_id Post ID. | |
| 397 | + * | |
| 398 | + * @return bool|WP_Term | |
| 399 | + */ | |
| 400 | + public function get_menu_by_post_id( $post_id = null ) { | |
| 401 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 402 | + return $this->new_instance->get_menu_by_post_id( $post_id ); | |
| 754 | 403 | } |
| 755 | 404 | |
| 756 | - $terms = get_the_terms( $post_id, self::MENU_TAX ); | |
| 757 | - | |
| 758 | - if ( ! is_array( $terms ) ) { | |
| 759 | - return false; | |
| 405 | + /** | |
| 406 | + * Fires on a menu edit page. We might have drag-n-drop reordered | |
| 407 | + * | |
| 408 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 409 | + */ | |
| 410 | + public function maybe_reorder_menu_items() { | |
| 411 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 412 | + $this->new_instance->maybe_reorder_menu_items(); | |
| 760 | 413 | } |
| 761 | 414 | |
| 762 | - return array_pop( $terms ); | |
| 763 | - } | |
| 764 | - | |
| 765 | - /** | |
| 766 | - * Fires on a menu edit page. We might have drag-n-drop reordered | |
| 767 | - */ | |
| 768 | - public function maybe_reorder_menu_items() { | |
| 769 | - // make sure we clicked our button. | |
| 770 | - if ( | |
| 771 | - empty( $_REQUEST['menu_reorder_submit'] ) | |
| 772 | - || __( 'Save New Order', 'jetpack' ) !== $_REQUEST['menu_reorder_submit'] | |
| 773 | - ) { | |
| 774 | - return; | |
| 415 | + /** | |
| 416 | + * Handle changes to menu items. | |
| 417 | + * (process actions, update data, enqueue necessary scripts). | |
| 418 | + * | |
| 419 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 420 | + * | |
| 421 | + * @return void | |
| 422 | + */ | |
| 423 | + public function edit_menu_items_page_load() { | |
| 424 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 425 | + $this->new_instance->edit_menu_items_page_load(); | |
| 775 | 426 | } |
| 776 | 427 | |
| 777 | - // make sure we have the nonce. | |
| 778 | - if ( | |
| 779 | - empty( $_REQUEST['drag-drop-reorder'] ) | |
| 780 | - || ! wp_verify_nonce( sanitize_key( $_REQUEST['drag-drop-reorder'] ), 'drag-drop-reorder' ) | |
| 781 | - ) { | |
| 782 | - return; | |
| 428 | + /** | |
| 429 | + * Process actions to move menu items around. | |
| 430 | + * | |
| 431 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 432 | + * | |
| 433 | + * @return void | |
| 434 | + */ | |
| 435 | + public function handle_menu_item_actions() { | |
| 436 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 437 | + $this->new_instance->handle_menu_item_actions(); | |
| 783 | 438 | } |
| 784 | 439 | |
| 785 | - // make sure we have data to work with. | |
| 786 | - if ( empty( $_REQUEST['nova_menu_term'] ) || empty( $_REQUEST['nova_order'] ) ) { | |
| 787 | - return; | |
| 440 | + /** | |
| 441 | + * Add menu title rows to the list table | |
| 442 | + * | |
| 443 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 444 | + * | |
| 445 | + * @param WP_Post $post The Post object. | |
| 446 | + * | |
| 447 | + * @return void | |
| 448 | + */ | |
| 449 | + public function show_menu_titles_in_menu_item_list( $post ) { | |
| 450 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 451 | + $this->new_instance->show_menu_titles_in_menu_item_list( $post ); | |
| 788 | 452 | } |
| 789 | 453 | |
| 790 | - $term_pairs = array_map( 'absint', $_REQUEST['nova_menu_term'] ); | |
| 791 | - $order_pairs = array_map( 'absint', $_REQUEST['nova_order'] ); | |
| 454 | + /* Edit Many Items */ | |
| 792 | 455 | |
| 793 | - foreach ( $order_pairs as $id => $menu_order ) { | |
| 794 | - $id = absint( $id ); | |
| 795 | - unset( $order_pairs[ $id ] ); | |
| 796 | - if ( $id < 0 ) { | |
| 797 | - continue; | |
| 798 | - } | |
| 799 | - | |
| 800 | - $post = get_post( $id ); | |
| 801 | - if ( ! $post ) { | |
| 802 | - continue; | |
| 803 | - } | |
| 804 | - | |
| 805 | - // save a write if the order hasn't changed | |
| 806 | - if ( (int) $menu_order !== $post->menu_order ) { | |
| 807 | - $args = array( | |
| 808 | - 'ID' => $id, | |
| 809 | - 'menu_order' => $menu_order, | |
| 810 | - ); | |
| 811 | - wp_update_post( $args ); | |
| 812 | - } | |
| 813 | - | |
| 814 | - // save a write if the term hasn't changed | |
| 815 | - if ( (int) $term_pairs[ $id ] !== $this->get_menu_by_post_id( $id )->term_id ) { | |
| 816 | - wp_set_object_terms( $id, $term_pairs[ $id ], self::MENU_TAX ); | |
| 817 | - } | |
| 456 | + /** | |
| 457 | + * Handle form submissions that aim to add many menu items at once. | |
| 458 | + * (process posted data and enqueue necessary script). | |
| 459 | + * | |
| 460 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 461 | + * | |
| 462 | + * @return void | |
| 463 | + */ | |
| 464 | + public function add_many_new_items_page_load() { | |
| 465 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 466 | + $this->new_instance->add_many_new_items_page_load(); | |
| 818 | 467 | } |
| 819 | 468 | |
| 820 | - $redirect = add_query_arg( | |
| 821 | - array( | |
| 822 | - 'post_type' => self::MENU_ITEM_POST_TYPE, | |
| 823 | - 'nova_reordered' => '1', | |
| 824 | - ), | |
| 825 | - admin_url( 'edit.php' ) | |
| 826 | - ); | |
| 827 | - wp_safe_redirect( $redirect ); | |
| 828 | - exit; | |
| 829 | - } | |
| 830 | - | |
| 831 | - /** | |
| 832 | - * Handle changes to menu items. | |
| 833 | - * (process actions, update data, enqueue necessary scripts). | |
| 834 | - * | |
| 835 | - * @return void | |
| 836 | - */ | |
| 837 | - public function edit_menu_items_page_load() { | |
| 838 | - if ( isset( $_GET['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- we process the form and check nonces in handle_menu_item_actions. | |
| 839 | - $this->handle_menu_item_actions(); | |
| 469 | + /** | |
| 470 | + * Enqueue script to create many items at once. | |
| 471 | + * | |
| 472 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 473 | + * | |
| 474 | + * @return void | |
| 475 | + */ | |
| 476 | + public function enqueue_many_items_scripts() { | |
| 477 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 478 | + $this->new_instance->enqueue_many_items_scripts(); | |
| 840 | 479 | } |
| 841 | 480 | |
| 842 | - $this->maybe_reorder_menu_items(); | |
| 843 | - | |
| 844 | - wp_enqueue_script( | |
| 845 | - 'nova-drag-drop', | |
| 846 | - Assets::get_file_url_for_environment( | |
| 847 | - '_inc/build/custom-post-types/js/nova-drag-drop.min.js', | |
| 848 | - 'modules/custom-post-types/js/nova-drag-drop.js' | |
| 849 | - ), | |
| 850 | - array( 'jquery', 'jquery-ui-sortable' ), | |
| 851 | - $this->version, | |
| 852 | - true | |
| 853 | - ); | |
| 854 | - | |
| 855 | - wp_localize_script( | |
| 856 | - 'nova-drag-drop', | |
| 857 | - '_novaDragDrop', | |
| 858 | - array( | |
| 859 | - 'nonce' => wp_create_nonce( 'drag-drop-reorder' ), | |
| 860 | - 'nonceName' => 'drag-drop-reorder', | |
| 861 | - 'reorder' => __( 'Save New Order', 'jetpack' ), | |
| 862 | - 'reorderName' => 'menu_reorder_submit', | |
| 863 | - ) | |
| 864 | - ); | |
| 865 | - add_action( 'the_post', array( $this, 'show_menu_titles_in_menu_item_list' ) ); | |
| 866 | - } | |
| 867 | - | |
| 868 | - /** | |
| 869 | - * Process actions to move menu items around. | |
| 870 | - * | |
| 871 | - * @return void | |
| 872 | - */ | |
| 873 | - public function handle_menu_item_actions() { | |
| 874 | - if ( isset( $_GET['action'] ) ) { | |
| 875 | - $action = (string) wp_unslash( $_GET['action'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- we check for nonces below, and check against specific strings in switch statement. | |
| 876 | - } else { | |
| 877 | - return; | |
| 481 | + /** | |
| 482 | + * Process form request to create many items at once. | |
| 483 | + * | |
| 484 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 485 | + * | |
| 486 | + * @return void | |
| 487 | + */ | |
| 488 | + public function process_form_request() { | |
| 489 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 490 | + $this->new_instance->process_form_request(); | |
| 878 | 491 | } |
| 879 | 492 | |
| 880 | - switch ( $action ) { | |
| 881 | - case 'move-item-up': | |
| 882 | - case 'move-item-down': | |
| 883 | - $reorder = false; | |
| 884 | - | |
| 885 | - if ( empty( $_GET['post_id'] ) ) { | |
| 886 | - break; | |
| 887 | - } | |
| 888 | - | |
| 889 | - $post_id = (int) $_GET['post_id']; | |
| 890 | - | |
| 891 | - $term = $this->get_menu_item_menu_leaf( $post_id ); | |
| 892 | - | |
| 893 | - // Get all posts in that term. | |
| 894 | - $query = new WP_Query( | |
| 895 | - array( | |
| 896 | - 'taxonomy' => self::MENU_TAX, | |
| 897 | - 'term' => $term->slug, | |
| 898 | - ) | |
| 899 | - ); | |
| 900 | - | |
| 901 | - $order = array(); | |
| 902 | - foreach ( $query->posts as $post ) { | |
| 903 | - $order[] = $post->ID; | |
| 904 | - } | |
| 905 | - | |
| 906 | - if ( 'move-item-up' === $action ) { | |
| 907 | - check_admin_referer( 'nova_move_item_up_' . $post_id ); | |
| 908 | - | |
| 909 | - $first_post_id = $order[0]; | |
| 910 | - if ( $post_id === $first_post_id ) { | |
| 911 | - break; | |
| 912 | - } | |
| 913 | - | |
| 914 | - foreach ( $order as $menu_order => $order_post_id ) { | |
| 915 | - if ( $post_id !== $order_post_id ) { | |
| 916 | - continue; | |
| 917 | - } | |
| 918 | - | |
| 919 | - $swap_post_id = $order[ $menu_order - 1 ]; | |
| 920 | - $order[ $menu_order - 1 ] = $post_id; | |
| 921 | - $order[ $menu_order ] = $swap_post_id; | |
| 922 | - | |
| 923 | - $reorder = true; | |
| 924 | - break; | |
| 925 | - } | |
| 926 | - } else { | |
| 927 | - check_admin_referer( 'nova_move_item_down_' . $post_id ); | |
| 928 | - | |
| 929 | - $last_post_id = end( $order ); | |
| 930 | - if ( $post_id === $last_post_id ) { | |
| 931 | - break; | |
| 932 | - } | |
| 933 | - | |
| 934 | - foreach ( $order as $menu_order => $order_post_id ) { | |
| 935 | - if ( $post_id !== $order_post_id ) { | |
| 936 | - continue; | |
| 937 | - } | |
| 938 | - | |
| 939 | - $swap_post_id = $order[ $menu_order + 1 ]; | |
| 940 | - $order[ $menu_order + 1 ] = $post_id; | |
| 941 | - $order[ $menu_order ] = $swap_post_id; | |
| 942 | - | |
| 943 | - $reorder = true; | |
| 944 | - } | |
| 945 | - } | |
| 946 | - | |
| 947 | - if ( $reorder ) { | |
| 948 | - foreach ( $order as $menu_order => $id ) { | |
| 949 | - wp_update_post( compact( 'id', 'menu_order' ) ); | |
| 950 | - } | |
| 951 | - } | |
| 952 | - | |
| 953 | - break; | |
| 954 | - case 'move-menu-up': | |
| 955 | - case 'move-menu-down': | |
| 956 | - $reorder = false; | |
| 957 | - | |
| 958 | - if ( empty( $_GET['term_id'] ) ) { | |
| 959 | - break; | |
| 960 | - } | |
| 961 | - | |
| 962 | - $term_id = (int) $_GET['term_id']; | |
| 963 | - | |
| 964 | - $terms = $this->get_menus(); | |
| 965 | - | |
| 966 | - $order = array(); | |
| 967 | - foreach ( $terms as $term ) { | |
| 968 | - $order[] = $term->term_id; | |
| 969 | - } | |
| 970 | - | |
| 971 | - if ( 'move-menu-up' === $action ) { | |
| 972 | - check_admin_referer( 'nova_move_menu_up_' . $term_id ); | |
| 973 | - | |
| 974 | - $first_term_id = $order[0]; | |
| 975 | - if ( $term_id === $first_term_id ) { | |
| 976 | - break; | |
| 977 | - } | |
| 978 | - | |
| 979 | - foreach ( $order as $menu_order => $order_term_id ) { | |
| 980 | - if ( $term_id !== $order_term_id ) { | |
| 981 | - continue; | |
| 982 | - } | |
| 983 | - | |
| 984 | - $swap_term_id = $order[ $menu_order - 1 ]; | |
| 985 | - $order[ $menu_order - 1 ] = $term_id; | |
| 986 | - $order[ $menu_order ] = $swap_term_id; | |
| 987 | - | |
| 988 | - $reorder = true; | |
| 989 | - break; | |
| 990 | - } | |
| 991 | - } else { | |
| 992 | - check_admin_referer( 'nova_move_menu_down_' . $term_id ); | |
| 993 | - | |
| 994 | - $last_term_id = end( $order ); | |
| 995 | - if ( $term_id === $last_term_id ) { | |
| 996 | - break; | |
| 997 | - } | |
| 998 | - | |
| 999 | - foreach ( $order as $menu_order => $order_term_id ) { | |
| 1000 | - if ( $term_id !== $order_term_id ) { | |
| 1001 | - continue; | |
| 1002 | - } | |
| 1003 | - | |
| 1004 | - $swap_term_id = $order[ $menu_order + 1 ]; | |
| 1005 | - $order[ $menu_order + 1 ] = $term_id; | |
| 1006 | - $order[ $menu_order ] = $swap_term_id; | |
| 1007 | - | |
| 1008 | - $reorder = true; | |
| 1009 | - } | |
| 1010 | - } | |
| 1011 | - | |
| 1012 | - if ( $reorder ) { | |
| 1013 | - update_option( 'nova_menu_order', $order ); | |
| 1014 | - } | |
| 1015 | - | |
| 1016 | - break; | |
| 1017 | - default: | |
| 1018 | - return; | |
| 493 | + /** | |
| 494 | + * Admin page contents for adding many menu items at once. | |
| 495 | + * | |
| 496 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 497 | + * | |
| 498 | + * @return void | |
| 499 | + */ | |
| 500 | + public function add_many_new_items_page() { | |
| 501 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 502 | + $this->new_instance->add_many_new_items_page(); | |
| 1019 | 503 | } |
| 1020 | 504 | |
| 1021 | - $redirect = add_query_arg( | |
| 1022 | - array( | |
| 1023 | - 'post_type' => self::MENU_ITEM_POST_TYPE, | |
| 1024 | - 'nova_reordered' => '1', | |
| 1025 | - ), | |
| 1026 | - admin_url( 'edit.php' ) | |
| 1027 | - ); | |
| 1028 | - wp_safe_redirect( $redirect ); | |
| 1029 | - exit; | |
| 1030 | - } | |
| 505 | + /* Edit One Item */ | |
| 1031 | 506 | |
| 1032 | - /** | |
| 1033 | - * Add menu title rows to the list table | |
| 1034 | - * | |
| 1035 | - * @param WP_Post $post The Post object. | |
| 1036 | - * | |
| 1037 | - * @return void | |
| 1038 | - */ | |
| 1039 | - public function show_menu_titles_in_menu_item_list( $post ) { | |
| 1040 | - global $wp_list_table; | |
| 1041 | - | |
| 1042 | - static $last_term_id = false; | |
| 1043 | - | |
| 1044 | - $term = $this->get_menu_item_menu_leaf( $post->ID ); | |
| 1045 | - | |
| 1046 | - $term_id = $term instanceof WP_Term ? $term->term_id : null; | |
| 1047 | - | |
| 1048 | - if ( false !== $last_term_id && $last_term_id === $term_id ) { | |
| 1049 | - return; | |
| 507 | + /** | |
| 508 | + * Create admin meta box to save price for a menu item, | |
| 509 | + * and add script to add extra checkboxes to the UI. | |
| 510 | + * | |
| 511 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 512 | + * | |
| 513 | + * @return void | |
| 514 | + */ | |
| 515 | + public function register_menu_item_meta_boxes() { | |
| 516 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 517 | + $this->new_instance->register_menu_item_meta_boxes(); | |
| 1050 | 518 | } |
| 1051 | 519 | |
| 1052 | - if ( $term_id === null ) { | |
| 1053 | - $last_term_id = null; | |
| 1054 | - $term_name = ''; | |
| 1055 | - $parent_count = 0; | |
| 1056 | - } else { | |
| 1057 | - $last_term_id = $term->term_id; | |
| 1058 | - $term_name = $term->name; | |
| 1059 | - $parent_count = 0; | |
| 1060 | - $current_term = $term; | |
| 1061 | - while ( $current_term->parent ) { | |
| 1062 | - ++$parent_count; | |
| 1063 | - $current_term = get_term( $current_term->parent, self::MENU_TAX ); | |
| 1064 | - } | |
| 520 | + /** | |
| 521 | + * Meta box to edit the price of a menu item. | |
| 522 | + * | |
| 523 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 524 | + * | |
| 525 | + * @param WP_Post $post The post object. | |
| 526 | + * | |
| 527 | + * @return void | |
| 528 | + */ | |
| 529 | + public function menu_item_price_meta_box( $post ) { | |
| 530 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 531 | + $this->new_instance->menu_item_price_meta_box( $post ); | |
| 1065 | 532 | } |
| 1066 | 533 | |
| 1067 | - $non_order_column_count = $wp_list_table->get_column_count() - 1; | |
| 1068 | - | |
| 1069 | - $screen = get_current_screen(); | |
| 1070 | - | |
| 1071 | - $url = admin_url( $screen->parent_file ); | |
| 1072 | - | |
| 1073 | - $up_url = add_query_arg( | |
| 1074 | - array( | |
| 1075 | - 'action' => 'move-menu-up', | |
| 1076 | - 'term_id' => (int) $term_id, | |
| 1077 | - ), | |
| 1078 | - wp_nonce_url( $url, 'nova_move_menu_up_' . $term_id ) | |
| 1079 | - ); | |
| 1080 | - | |
| 1081 | - $down_url = add_query_arg( | |
| 1082 | - array( | |
| 1083 | - 'action' => 'move-menu-down', | |
| 1084 | - 'term_id' => (int) $term_id, | |
| 1085 | - ), | |
| 1086 | - wp_nonce_url( $url, 'nova_move_menu_down_' . $term_id ) | |
| 1087 | - ); | |
| 1088 | - | |
| 1089 | - ?> | |
| 1090 | - <tr class="no-items menu-label-row" data-term_id="<?php echo esc_attr( $term_id ); ?>"> | |
| 1091 | - <td class="colspanchange" colspan="<?php echo (int) $non_order_column_count; ?>"> | |
| 1092 | - <h3> | |
| 1093 | - <?php | |
| 1094 | - echo str_repeat( ' — ', (int) $parent_count ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- nothing to escape here. | |
| 1095 | - | |
| 1096 | - if ( $term instanceof WP_Term ) { | |
| 1097 | - echo esc_html( sanitize_term_field( 'name', $term_name, $term_id, self::MENU_TAX, 'display' ) ); | |
| 1098 | - edit_term_link( __( 'edit', 'jetpack' ), '<span class="edit-nova-section"><span class="dashicon dashicon-edit"></span>', '</span>', $term ); | |
| 1099 | - | |
| 1100 | - } else { | |
| 1101 | - esc_html_e( 'Uncategorized', 'jetpack' ); | |
| 1102 | - } | |
| 1103 | - ?> | |
| 1104 | - </h3> | |
| 1105 | - </td> | |
| 1106 | - <td> | |
| 1107 | - <?php if ( $term instanceof WP_Term ) { ?> | |
| 1108 | - <a class="nova-move-menu-up" title="<?php esc_attr_e( 'Move menu section up', 'jetpack' ); ?>" href="<?php echo esc_url( $up_url ); ?>"><?php echo esc_html_x( 'UP', 'indicates movement (up or down)', 'jetpack' ); ?></a> | |
| 1109 | - <br /> | |
| 1110 | - <a class="nova-move-menu-down" title="<?php esc_attr_e( 'Move menu section down', 'jetpack' ); ?>" href="<?php echo esc_url( $down_url ); ?>"><?php echo esc_html_x( 'DOWN', 'indicates movement (up or down)', 'jetpack' ); ?></a> | |
| 1111 | - <?php } ?> | |
| 1112 | - </td> | |
| 1113 | - </tr> | |
| 1114 | - <?php | |
| 1115 | - } | |
| 1116 | - | |
| 1117 | - /* Edit Many Items */ | |
| 1118 | - | |
| 1119 | - /** | |
| 1120 | - * Handle form submissions that aim to add many menu items at once. | |
| 1121 | - * (process posted data and enqueue necessary script). | |
| 1122 | - * | |
| 1123 | - * @return void | |
| 1124 | - */ | |
| 1125 | - public function add_many_new_items_page_load() { | |
| 1126 | - if ( | |
| 1127 | - isset( $_SERVER['REQUEST_METHOD'] ) | |
| 1128 | - && 'POST' === strtoupper( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) ) | |
| 1129 | - ) { | |
| 1130 | - $this->process_form_request(); | |
| 1131 | - exit; | |
| 534 | + /** | |
| 535 | + * Save the price of a menu item. | |
| 536 | + * | |
| 537 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 538 | + * | |
| 539 | + * @param int $post_id Post ID. | |
| 540 | + */ | |
| 541 | + public function add_post_meta( $post_id ) { | |
| 542 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 543 | + $this->new_instance->add_post_meta( $post_id ); | |
| 1132 | 544 | } |
| 1133 | 545 | |
| 1134 | - $this->enqueue_many_items_scripts(); | |
| 1135 | - } | |
| 546 | + /* Data */ | |
| 1136 | 547 | |
| 1137 | - /** | |
| 1138 | - * Enqueue script to create many items at once. | |
| 1139 | - * | |
| 1140 | - * @return void | |
| 1141 | - */ | |
| 1142 | - public function enqueue_many_items_scripts() { | |
| 1143 | - wp_enqueue_script( | |
| 1144 | - 'nova-many-items', | |
| 1145 | - Assets::get_file_url_for_environment( | |
| 1146 | - '_inc/build/custom-post-types/js/many-items.min.js', | |
| 1147 | - 'modules/custom-post-types/js/many-items.js' | |
| 1148 | - ), | |
| 1149 | - array( 'jquery' ), | |
| 1150 | - $this->version, | |
| 1151 | - true | |
| 1152 | - ); | |
| 1153 | - } | |
| 1154 | - | |
| 1155 | - /** | |
| 1156 | - * Process form request to create many items at once. | |
| 1157 | - * | |
| 1158 | - * @return void | |
| 1159 | - */ | |
| 1160 | - public function process_form_request() { | |
| 1161 | - if ( ! isset( $_POST['nova_title'] ) || ! is_array( $_POST['nova_title'] ) ) { | |
| 1162 | - return; | |
| 548 | + /** | |
| 549 | + * Get ordered array of menu items. | |
| 550 | + * | |
| 551 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 552 | + * | |
| 553 | + * @param array $args Optional argumments. | |
| 554 | + * | |
| 555 | + * @return array | |
| 556 | + */ | |
| 557 | + public function get_menus( $args = array() ) { | |
| 558 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 559 | + return $this->new_instance->get_menus( $args ); | |
| 1163 | 560 | } |
| 1164 | 561 | |
| 1165 | - $is_ajax = ! empty( $_POST['ajax'] ); | |
| 1166 | - | |
| 1167 | - if ( $is_ajax ) { | |
| 1168 | - check_ajax_referer( 'nova_many_items' ); | |
| 1169 | - } else { | |
| 1170 | - check_admin_referer( 'nova_many_items' ); | |
| 562 | + /** | |
| 563 | + * Get first menu taxonomy "leaf". | |
| 564 | + * | |
| 565 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 566 | + * | |
| 567 | + * @param int $post_id Post ID. | |
| 568 | + * | |
| 569 | + * @return bool|WP_Term|WP_Error|null | |
| 570 | + */ | |
| 571 | + public function get_menu_item_menu_leaf( $post_id ) { | |
| 572 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 573 | + return $this->new_instance->get_menu_item_menu_leaf( $post_id ); | |
| 1171 | 574 | } |
| 1172 | 575 | |
| 1173 | - /* | |
| 1174 | - * $_POST is already slashed | |
| 1175 | - * phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 576 | + /** | |
| 577 | + * Get a list of the labels linked to a menu item. | |
| 578 | + * | |
| 579 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 580 | + * | |
| 581 | + * @param int $post_id Post ID. | |
| 582 | + * | |
| 583 | + * @return void | |
| 1176 | 584 | */ |
| 1177 | - foreach ( array_keys( $_POST['nova_title'] ) as $key ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- we sanitize below. | |
| 1178 | - $post_details = array( | |
| 1179 | - 'post_status' => 'publish', | |
| 1180 | - 'post_type' => self::MENU_ITEM_POST_TYPE, | |
| 1181 | - 'post_content' => ! empty( $_POST['nova_content'] ) && ! empty( $_POST['nova_content'][ $key ] ) | |
| 1182 | - ? sanitize_text_field( $_POST['nova_content'][ $key ] ) | |
| 1183 | - : '', | |
| 1184 | - 'post_title' => isset( $_POST['nova_title'][ $key ] ) | |
| 1185 | - ? sanitize_title( $_POST['nova_title'][ $key ] ) | |
| 1186 | - : '', | |
| 1187 | - 'tax_input' => array( | |
| 1188 | - self::MENU_ITEM_LABEL_TAX => isset( $_POST['nova_labels'][ $key ] ) | |
| 1189 | - ? sanitize_meta( self::MENU_ITEM_LABEL_TAX, $_POST['nova_labels'][ $key ], 'term' ) | |
| 1190 | - : null, | |
| 1191 | - self::MENU_TAX => isset( $_POST['nova_menu_tax'] ) | |
| 1192 | - ? sanitize_meta( self::MENU_TAX, $_POST['nova_menu_tax'], 'term' ) | |
| 1193 | - : null, | |
| 1194 | - ), | |
| 1195 | - ); | |
| 1196 | - | |
| 1197 | - $post_id = wp_insert_post( $post_details ); | |
| 1198 | - if ( ! $post_id || is_wp_error( $post_id ) ) { | |
| 1199 | - continue; | |
| 1200 | - } | |
| 1201 | - | |
| 1202 | - $this->set_price( | |
| 1203 | - $post_id, | |
| 1204 | - isset( $_POST['nova_price'][ $key ] ) | |
| 1205 | - ? sanitize_meta( 'nova_price', $_POST['nova_price'][ $key ], 'post' ) | |
| 1206 | - : '' | |
| 1207 | - ); | |
| 1208 | - // phpcs:enable WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 1209 | - | |
| 1210 | - if ( $is_ajax ) : | |
| 1211 | - $post = get_post( $post_id ); | |
| 1212 | - $GLOBALS['post'] = $post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | |
| 1213 | - setup_postdata( $post ); | |
| 1214 | - | |
| 1215 | - ?> | |
| 1216 | - <td><?php the_title(); ?></td> | |
| 1217 | - <td class="nova-price"><?php $this->display_price(); ?></td> | |
| 1218 | - <td><?php $this->list_labels( $post_id ); ?></td> | |
| 1219 | - <td><?php the_content(); ?></td> | |
| 1220 | - <?php | |
| 1221 | - endif; | |
| 1222 | - | |
| 1223 | - endforeach; | |
| 1224 | - | |
| 1225 | - if ( $is_ajax ) { | |
| 1226 | - exit; | |
| 585 | + public function list_labels( $post_id = 0 ) { | |
| 586 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 587 | + $this->new_instance->list_labels( $post_id ); | |
| 1227 | 588 | } |
| 1228 | 589 | |
| 1229 | - wp_safe_redirect( admin_url( 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE ) ); | |
| 1230 | - exit; | |
| 1231 | - } | |
| 1232 | - | |
| 1233 | - /** | |
| 1234 | - * Admin page contents for adding many menu items at once. | |
| 1235 | - * | |
| 1236 | - * @return void | |
| 1237 | - */ | |
| 1238 | - public function add_many_new_items_page() { | |
| 1239 | - ?> | |
| 1240 | - <div class="wrap"> | |
| 1241 | - <h2><?php esc_html_e( 'Add Many Items', 'jetpack' ); ?></h2> | |
| 1242 | - | |
| 1243 | - <p> | |
| 1244 | - <?php | |
| 1245 | - echo wp_kses( | |
| 1246 | - __( 'Use the <kbd>TAB</kbd> key on your keyboard to move between colums and the <kbd>ENTER</kbd> or <kbd>RETURN</kbd> key to save each row and move on to the next.', 'jetpack' ), | |
| 1247 | - array( | |
| 1248 | - 'kbd' => array(), | |
| 1249 | - ) | |
| 1250 | - ); | |
| 1251 | - ?> | |
| 1252 | - </p> | |
| 1253 | - | |
| 1254 | - <form method="post" action="" enctype="multipart/form-data"> | |
| 1255 | - <p> | |
| 1256 | - <h3><?php esc_html_e( 'Add to section:', 'jetpack' ); ?> | |
| 1257 | - <?php | |
| 1258 | - wp_dropdown_categories( | |
| 1259 | - array( | |
| 1260 | - 'id' => 'nova-menu-tax', | |
| 1261 | - 'name' => 'nova_menu_tax', | |
| 1262 | - 'taxonomy' => self::MENU_TAX, | |
| 1263 | - 'hide_empty' => false, | |
| 1264 | - 'hierarchical' => true, | |
| 1265 | - ) | |
| 1266 | - ); | |
| 1267 | - ?> | |
| 1268 | - </h3></p> | |
| 1269 | - | |
| 1270 | - <table class="many-items-table wp-list-table widefat"> | |
| 1271 | - <thead> | |
| 1272 | - <tr> | |
| 1273 | - <th scope="col"><?php esc_html_e( 'Name', 'jetpack' ); ?></th> | |
| 1274 | - <th scope="col" class="nova-price"><?php esc_html_e( 'Price', 'jetpack' ); ?></th> | |
| 1275 | - <th scope="col"> | |
| 1276 | - <?php | |
| 1277 | - echo wp_kses( | |
| 1278 | - __( 'Labels: <small>spicy, favorite, etc. <em>Separate Labels with commas</em></small>', 'jetpack' ), | |
| 1279 | - array( | |
| 1280 | - 'small' => array(), | |
| 1281 | - 'em' => array(), | |
| 1282 | - ) | |
| 1283 | - ); | |
| 1284 | - ?> | |
| 1285 | - </th> | |
| 1286 | - <th scope="col"><?php esc_html_e( 'Description', 'jetpack' ); ?></th> | |
| 1287 | - </tr> | |
| 1288 | - </thead> | |
| 1289 | - <tbody> | |
| 1290 | - <tr> | |
| 1291 | - <td><input type="text" name="nova_title[]" aria-required="true" /></td> | |
| 1292 | - <td class="nova-price"><input type="text" name="nova_price[]" /></td> | |
| 1293 | - <td><input type="text" name="nova_labels[]" /></td> | |
| 1294 | - <td><textarea name="nova_content[]" cols="20" rows="1"></textarea> | |
| 1295 | - </tr> | |
| 1296 | - </tbody> | |
| 1297 | - <tbody> | |
| 1298 | - <tr> | |
| 1299 | - <td><input type="text" name="nova_title[]" aria-required="true" /></td> | |
| 1300 | - <td class="nova-price"><input type="text" name="nova_price[]" /></td> | |
| 1301 | - <td><input type="text" name="nova_labels[]" /></td> | |
| 1302 | - <td><textarea name="nova_content[]" cols="20" rows="1"></textarea> | |
| 1303 | - </tr> | |
| 1304 | - </tbody> | |
| 1305 | - <tfoot> | |
| 1306 | - <tr> | |
| 1307 | - <th><a class="button button-secondary nova-new-row"><span class="dashicon dashicon-plus"></span> <?php esc_html_e( 'New Row', 'jetpack' ); ?></a></th> | |
| 1308 | - <th class="nova-price"></th> | |
| 1309 | - <th></th> | |
| 1310 | - <th></th> | |
| 1311 | - </tr> | |
| 1312 | - </tfoot> | |
| 1313 | - </table> | |
| 1314 | - | |
| 1315 | - <p class="submit"> | |
| 1316 | - <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Add These New Menu Items', 'jetpack' ); ?>" /> | |
| 1317 | - <?php wp_nonce_field( 'nova_many_items' ); ?> | |
| 1318 | - </p> | |
| 1319 | - </form> | |
| 1320 | - </div> | |
| 1321 | - <?php | |
| 1322 | - } | |
| 1323 | - | |
| 1324 | - /* Edit One Item */ | |
| 1325 | - | |
| 1326 | - /** | |
| 1327 | - * Create admin meta box to save price for a menu item, | |
| 1328 | - * and add script to add extra checkboxes to the UI. | |
| 1329 | - * | |
| 1330 | - * @return void | |
| 1331 | - */ | |
| 1332 | - public function register_menu_item_meta_boxes() { | |
| 1333 | - wp_enqueue_script( 'nova-menu-checkboxes' ); | |
| 1334 | - | |
| 1335 | - add_meta_box( | |
| 1336 | - 'menu_item_price', | |
| 1337 | - __( 'Price', 'jetpack' ), | |
| 1338 | - array( $this, 'menu_item_price_meta_box' ), | |
| 1339 | - null, | |
| 1340 | - 'side', | |
| 1341 | - 'high' | |
| 1342 | - ); | |
| 1343 | - } | |
| 1344 | - | |
| 1345 | - /** | |
| 1346 | - * Meta box to edit the price of a menu item. | |
| 1347 | - * | |
| 1348 | - * @param WP_Post $post The post object. | |
| 1349 | - * | |
| 1350 | - * @return void | |
| 1351 | - */ | |
| 1352 | - public function menu_item_price_meta_box( $post ) { | |
| 1353 | - printf( | |
| 1354 | - '<label for="nova-price-%1$s" class="screen-reader-text">%2$s</label><input type="text" id="nova-price-%1$s" class="widefat" name="nova_price[%1$s]" value="%3$s" />', | |
| 1355 | - (int) $post->ID, | |
| 1356 | - esc_html__( 'Price', 'jetpack' ), | |
| 1357 | - esc_attr( $this->get_price( (int) $post->ID ) ) | |
| 1358 | - ); | |
| 1359 | - } | |
| 1360 | - | |
| 1361 | - /** | |
| 1362 | - * Save the price of a menu item. | |
| 1363 | - * | |
| 1364 | - * @param int $post_id Post ID. | |
| 1365 | - */ | |
| 1366 | - public function add_post_meta( $post_id ) { | |
| 1367 | - if ( ! isset( $_POST['nova_price'][ $post_id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce handling happens via core, since we hook into wp_insert_post. | |
| 1368 | - return; | |
| 590 | + /** | |
| 591 | + * Get a list of the labels linked to a menu item, with links to manage them. | |
| 592 | + * | |
| 593 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 594 | + * | |
| 595 | + * @param int $post_id Post ID. | |
| 596 | + * | |
| 597 | + * @return void | |
| 598 | + */ | |
| 599 | + public function list_admin_labels( $post_id = 0 ) { | |
| 600 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 601 | + $this->new_instance->list_admin_labels( $post_id ); | |
| 1369 | 602 | } |
| 1370 | 603 | |
| 1371 | - $this->set_price( | |
| 1372 | - $post_id, | |
| 1373 | - sanitize_meta( 'nova_price', wp_unslash( $_POST['nova_price'][ $post_id ] ), 'post' ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce handling happens via core, since we hook into wp_insert_post. | |
| 1374 | - ); | |
| 1375 | - } | |
| 1376 | - | |
| 1377 | - /* Data */ | |
| 1378 | - | |
| 1379 | - /** | |
| 1380 | - * Get ordered array of menu items. | |
| 1381 | - * | |
| 1382 | - * @param array $args Optional argumments. | |
| 1383 | - * | |
| 1384 | - * @return array | |
| 1385 | - */ | |
| 1386 | - public function get_menus( $args = array() ) { | |
| 1387 | - $args = wp_parse_args( | |
| 1388 | - $args, | |
| 1389 | - array( | |
| 1390 | - 'hide_empty' => false, | |
| 1391 | - ) | |
| 1392 | - ); | |
| 1393 | - $args['taxonomy'] = self::MENU_TAX; | |
| 1394 | - | |
| 1395 | - $terms = get_terms( $args ); | |
| 1396 | - if ( ! $terms || is_wp_error( $terms ) ) { | |
| 1397 | - return array(); | |
| 604 | + /** | |
| 605 | + * Update post meta with the price defined in meta box. | |
| 606 | + * | |
| 607 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 608 | + * | |
| 609 | + * @param int $post_id Post ID. | |
| 610 | + * @param string $price Price. | |
| 611 | + * | |
| 612 | + * @return int|bool | |
| 613 | + */ | |
| 614 | + public function set_price( $post_id = 0, $price = '' ) { | |
| 615 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 616 | + return $this->new_instance->set_price( $post_id, $price ); | |
| 1398 | 617 | } |
| 1399 | 618 | |
| 1400 | - $terms_by_id = array(); | |
| 1401 | - foreach ( $terms as $term ) { | |
| 1402 | - $terms_by_id[ "{$term->term_id}" ] = $term; | |
| 619 | + /** | |
| 620 | + * Get the price of a menu item. | |
| 621 | + * | |
| 622 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 623 | + * | |
| 624 | + * @param int $post_id Post ID. | |
| 625 | + * | |
| 626 | + * @return bool|string | |
| 627 | + */ | |
| 628 | + public function get_price( $post_id = 0 ) { | |
| 629 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 630 | + return $this->new_instance->get_price( $post_id ); | |
| 1403 | 631 | } |
| 1404 | 632 | |
| 1405 | - $term_order = get_option( 'nova_menu_order', array() ); | |
| 1406 | - | |
| 1407 | - $return = array(); | |
| 1408 | - foreach ( $term_order as $term_id ) { | |
| 1409 | - if ( isset( $terms_by_id[ "$term_id" ] ) ) { | |
| 1410 | - $return[] = $terms_by_id[ "$term_id" ]; | |
| 1411 | - unset( $terms_by_id[ "$term_id" ] ); | |
| 1412 | - } | |
| 633 | + /** | |
| 634 | + * Echo the price of a menu item. | |
| 635 | + * | |
| 636 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 637 | + * | |
| 638 | + * @param int $post_id Post ID. | |
| 639 | + * | |
| 640 | + * @return void | |
| 641 | + */ | |
| 642 | + public function display_price( $post_id = 0 ) { | |
| 643 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 644 | + $this->new_instance->display_price( $post_id ); | |
| 1413 | 645 | } |
| 1414 | 646 | |
| 1415 | - foreach ( $terms_by_id as $term_id => $term ) { | |
| 1416 | - $return[] = $term; | |
| 1417 | - } | |
| 647 | + /* Menu Item Loop Markup */ | |
| 1418 | 648 | |
| 1419 | - return $return; | |
| 1420 | - } | |
| 1421 | - | |
| 1422 | - /** | |
| 1423 | - * Get first menu taxonomy "leaf". | |
| 1424 | - * | |
| 1425 | - * @param int $post_id Post ID. | |
| 1426 | - * | |
| 1427 | - * @return bool|WP_Term|WP_Error|null | |
| 1428 | - */ | |
| 1429 | - public function get_menu_item_menu_leaf( $post_id ) { | |
| 1430 | - // Get first menu taxonomy "leaf". | |
| 1431 | - $term_ids = wp_get_object_terms( $post_id, self::MENU_TAX, array( 'fields' => 'ids' ) ); | |
| 1432 | - | |
| 1433 | - foreach ( $term_ids as $term_id ) { | |
| 1434 | - $children = get_term_children( $term_id, self::MENU_TAX ); | |
| 1435 | - if ( ! $children ) { | |
| 1436 | - break; | |
| 1437 | - } | |
| 649 | + /** | |
| 650 | + * Get markup for a menu item. | |
| 651 | + * Note: Does not support nested loops. | |
| 652 | + * | |
| 653 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 654 | + * | |
| 655 | + * @param null|string $field The field to get the value for. | |
| 656 | + * | |
| 657 | + * @return array | |
| 658 | + */ | |
| 659 | + public function get_menu_item_loop_markup( $field = null ) { | |
| 660 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 661 | + return $this->new_instance->get_menu_item_loop_markup( $field ); | |
| 1438 | 662 | } |
| 1439 | 663 | |
| 1440 | - if ( ! isset( $term_id ) ) { | |
| 1441 | - return false; | |
| 664 | + /** | |
| 665 | + * Sets up the loop markup. | |
| 666 | + * Attached to the 'template_include' *filter*, | |
| 667 | + * which fires only during a real blog view (not in admin, feeds, etc.) | |
| 668 | + * | |
| 669 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 670 | + * | |
| 671 | + * @param string $template Template File. | |
| 672 | + * | |
| 673 | + * @return string Template File. VERY Important. | |
| 674 | + */ | |
| 675 | + public function setup_menu_item_loop_markup__in_filter( $template ) { | |
| 676 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 677 | + return $this->new_instance->setup_menu_item_loop_markup__in_filter( $template ); | |
| 1442 | 678 | } |
| 1443 | 679 | |
| 1444 | - return get_term( $term_id, self::MENU_TAX ); | |
| 1445 | - } | |
| 1446 | - | |
| 1447 | - /** | |
| 1448 | - * Get a list of the labels linked to a menu item. | |
| 1449 | - * | |
| 1450 | - * @param int $post_id Post ID. | |
| 1451 | - * | |
| 1452 | - * @return void | |
| 1453 | - */ | |
| 1454 | - public function list_labels( $post_id = 0 ) { | |
| 1455 | - $post = get_post( $post_id ); | |
| 1456 | - echo get_the_term_list( $post->ID, self::MENU_ITEM_LABEL_TAX, '', _x( ', ', 'Nova label separator', 'jetpack' ), '' ); | |
| 1457 | - } | |
| 1458 | - | |
| 1459 | - /** | |
| 1460 | - * Get a list of the labels linked to a menu item, with links to manage them. | |
| 1461 | - * | |
| 1462 | - * @param int $post_id Post ID. | |
| 1463 | - * | |
| 1464 | - * @return void | |
| 1465 | - */ | |
| 1466 | - public function list_admin_labels( $post_id = 0 ) { | |
| 1467 | - $post = get_post( $post_id ); | |
| 1468 | - $labels = get_the_terms( $post->ID, self::MENU_ITEM_LABEL_TAX ); | |
| 1469 | - if ( ! empty( $labels ) ) { | |
| 1470 | - $out = array(); | |
| 1471 | - foreach ( $labels as $label ) { | |
| 1472 | - $out[] = sprintf( | |
| 1473 | - '<a href="%s">%s</a>', | |
| 1474 | - esc_url( | |
| 1475 | - add_query_arg( | |
| 1476 | - array( | |
| 1477 | - 'post_type' => self::MENU_ITEM_POST_TYPE, | |
| 1478 | - 'taxonomy' => self::MENU_ITEM_LABEL_TAX, | |
| 1479 | - 'term' => $label->slug, | |
| 1480 | - ), | |
| 1481 | - 'edit.php' | |
| 1482 | - ) | |
| 1483 | - ), | |
| 1484 | - esc_html( | |
| 1485 | - sanitize_term_field( 'name', $label->name, $label->term_id, self::MENU_ITEM_LABEL_TAX, 'display' ) | |
| 1486 | - ) | |
| 1487 | - ); | |
| 1488 | - } | |
| 1489 | - | |
| 1490 | - echo implode( _x( ', ', 'Nova label separator', 'jetpack' ), $out ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- we build $out ourselves and escape things there. | |
| 1491 | - } else { | |
| 1492 | - esc_html_e( 'No Labels', 'jetpack' ); | |
| 680 | + /** | |
| 681 | + * If the Query is a Menu Item Query, start outputing the Menu Item Loop Marku | |
| 682 | + * Attached to the 'loop_start' action. | |
| 683 | + * | |
| 684 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 685 | + * | |
| 686 | + * @param WP_Query $query Post query. | |
| 687 | + * | |
| 688 | + * @return void | |
| 689 | + */ | |
| 690 | + public function start_menu_item_loop( $query ) { | |
| 691 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 692 | + $this->new_instance->start_menu_item_loop( $query ); | |
| 1493 | 693 | } |
| 1494 | - } | |
| 1495 | 694 | |
| 1496 | - /** | |
| 1497 | - * Update post meta with the price defined in meta box. | |
| 1498 | - * | |
| 1499 | - * @param int $post_id Post ID. | |
| 1500 | - * @param string $price Price. | |
| 1501 | - * | |
| 1502 | - * @return int|bool | |
| 1503 | - */ | |
| 1504 | - public function set_price( $post_id = 0, $price = '' ) { | |
| 1505 | - return update_post_meta( $post_id, 'nova_price', $price ); | |
| 1506 | - } | |
| 1507 | - | |
| 1508 | - /** | |
| 1509 | - * Get the price of a menu item. | |
| 1510 | - * | |
| 1511 | - * @param int $post_id Post ID. | |
| 1512 | - * | |
| 1513 | - * @return bool|string | |
| 1514 | - */ | |
| 1515 | - public function get_price( $post_id = 0 ) { | |
| 1516 | - return get_post_meta( $post_id, 'nova_price', true ); | |
| 1517 | - } | |
| 1518 | - | |
| 1519 | - /** | |
| 1520 | - * Echo the price of a menu item. | |
| 1521 | - * | |
| 1522 | - * @param int $post_id Post ID. | |
| 1523 | - * | |
| 1524 | - * @return void | |
| 1525 | - */ | |
| 1526 | - public function display_price( $post_id = 0 ) { | |
| 1527 | - echo esc_html( $this->get_price( $post_id ) ); | |
| 1528 | - } | |
| 1529 | - | |
| 1530 | - /* Menu Item Loop Markup */ | |
| 1531 | - | |
| 1532 | - /** | |
| 1533 | - * Get markup for a menu item. | |
| 1534 | - * Note: Does not support nested loops. | |
| 1535 | - * | |
| 1536 | - * @param null|string $field The field to get the value for. | |
| 1537 | - * | |
| 1538 | - * @return array | |
| 1539 | - */ | |
| 1540 | - public function get_menu_item_loop_markup( $field = null ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 1541 | - return $this->menu_item_loop_markup; | |
| 1542 | - } | |
| 1543 | - | |
| 1544 | - /** | |
| 1545 | - * Sets up the loop markup. | |
| 1546 | - * Attached to the 'template_include' *filter*, | |
| 1547 | - * which fires only during a real blog view (not in admin, feeds, etc.) | |
| 1548 | - * | |
| 1549 | - * @param string $template Template File. | |
| 1550 | - * | |
| 1551 | - * @return string Template File. VERY Important. | |
| 1552 | - */ | |
| 1553 | - public function setup_menu_item_loop_markup__in_filter( $template ) { | |
| 1554 | - add_action( 'loop_start', array( $this, 'start_menu_item_loop' ) ); | |
| 1555 | - | |
| 1556 | - return $template; | |
| 1557 | - } | |
| 1558 | - | |
| 1559 | - /** | |
| 1560 | - * If the Query is a Menu Item Query, start outputing the Menu Item Loop Marku | |
| 1561 | - * Attached to the 'loop_start' action. | |
| 1562 | - * | |
| 1563 | - * @param WP_Query $query Post query. | |
| 1564 | - * | |
| 1565 | - * @return void | |
| 1566 | - */ | |
| 1567 | - public function start_menu_item_loop( $query ) { | |
| 1568 | - if ( ! $this->is_menu_item_query( $query ) ) { | |
| 1569 | - return; | |
| 695 | + /** | |
| 696 | + * Outputs the Menu Item Loop Marku | |
| 697 | + * Attached to the 'the_post' action. | |
| 698 | + * | |
| 699 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 700 | + * | |
| 701 | + * @param WP_Post $post Post object. | |
| 702 | + * | |
| 703 | + * @return void | |
| 704 | + */ | |
| 705 | + public function menu_item_loop_each_post( $post ) { | |
| 706 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 707 | + $this->new_instance->menu_item_loop_each_post( $post ); | |
| 1570 | 708 | } |
| 1571 | 709 | |
| 1572 | - $this->menu_item_loop_last_term_id = false; | |
| 1573 | - $this->menu_item_loop_current_term = false; | |
| 1574 | - | |
| 1575 | - add_action( 'the_post', array( $this, 'menu_item_loop_each_post' ) ); | |
| 1576 | - add_action( 'loop_end', array( $this, 'stop_menu_item_loop' ) ); | |
| 1577 | - } | |
| 1578 | - | |
| 1579 | - /** | |
| 1580 | - * Outputs the Menu Item Loop Marku | |
| 1581 | - * Attached to the 'the_post' action. | |
| 1582 | - * | |
| 1583 | - * @param WP_Post $post Post object. | |
| 1584 | - * | |
| 1585 | - * @return void | |
| 1586 | - */ | |
| 1587 | - public function menu_item_loop_each_post( $post ) { | |
| 1588 | - $this->menu_item_loop_current_term = $this->get_menu_item_menu_leaf( $post->ID ); | |
| 1589 | - | |
| 1590 | - if ( | |
| 1591 | - false === $this->menu_item_loop_current_term | |
| 1592 | - || null === $this->menu_item_loop_current_term | |
| 1593 | - || is_wp_error( $this->menu_item_loop_current_term ) | |
| 1594 | - ) { | |
| 1595 | - return; | |
| 710 | + /** | |
| 711 | + * If the Query is a Menu Item Query, stop outputing the Menu Item Loop Marku | |
| 712 | + * Attached to the 'loop_end' action. | |
| 713 | + * | |
| 714 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 715 | + * | |
| 716 | + * @param WP_Query $query Post query. | |
| 717 | + * | |
| 718 | + * @return void | |
| 719 | + */ | |
| 720 | + public function stop_menu_item_loop( $query ) { | |
| 721 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 722 | + $this->new_instance->stop_menu_item_loop( $query ); | |
| 1596 | 723 | } |
| 1597 | 724 | |
| 1598 | - if ( false === $this->menu_item_loop_last_term_id ) { | |
| 1599 | - // We're at the very beginning of the loop | |
| 1600 | - | |
| 1601 | - $this->menu_item_loop_open_element( 'menu' ); // Start a new menu section | |
| 1602 | - $this->menu_item_loop_header(); // Output the menu's header | |
| 1603 | - } elseif ( $this->menu_item_loop_last_term_id !== $this->menu_item_loop_current_term->term_id ) { | |
| 1604 | - // We're not at the very beginning but still need to start a new menu section. End the previous menu section first. | |
| 1605 | - | |
| 1606 | - $this->menu_item_loop_close_element( 'menu' ); // End the previous menu section | |
| 1607 | - $this->menu_item_loop_open_element( 'menu' ); // Start a new menu section | |
| 1608 | - $this->menu_item_loop_header(); // Output the menu's header | |
| 725 | + /** | |
| 726 | + * Outputs the Menu Group Header | |
| 727 | + * | |
| 728 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 729 | + * | |
| 730 | + * @return void | |
| 731 | + */ | |
| 732 | + public function menu_item_loop_header() { | |
| 733 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 734 | + $this->new_instance->menu_item_loop_header(); | |
| 1609 | 735 | } |
| 1610 | 736 | |
| 1611 | - $this->menu_item_loop_last_term_id = $this->menu_item_loop_current_term->term_id; | |
| 1612 | - } | |
| 1613 | - | |
| 1614 | - /** | |
| 1615 | - * If the Query is a Menu Item Query, stop outputing the Menu Item Loop Marku | |
| 1616 | - * Attached to the 'loop_end' action. | |
| 1617 | - * | |
| 1618 | - * @param WP_Query $query Post query. | |
| 1619 | - * | |
| 1620 | - * @return void | |
| 1621 | - */ | |
| 1622 | - public function stop_menu_item_loop( $query ) { | |
| 1623 | - if ( ! $this->is_menu_item_query( $query ) ) { | |
| 1624 | - return; | |
| 1625 | - } | |
| 1626 | - | |
| 1627 | - remove_action( 'the_post', array( $this, 'menu_item_loop_each_post' ) ); | |
| 1628 | - remove_action( 'loop_start', array( $this, 'start_menu_item_loop' ) ); | |
| 1629 | - remove_action( 'loop_end', array( $this, 'stop_menu_item_loop' ) ); | |
| 1630 | - | |
| 1631 | - $this->menu_item_loop_close_element( 'menu' ); // End the last menu section | |
| 1632 | - } | |
| 1633 | - | |
| 1634 | - /** | |
| 1635 | - * Outputs the Menu Group Header | |
| 1636 | - * | |
| 1637 | - * @return void | |
| 1638 | - */ | |
| 1639 | - public function menu_item_loop_header() { | |
| 1640 | - $this->menu_item_loop_open_element( 'menu_header' ); | |
| 1641 | - $this->menu_item_loop_open_element( 'menu_title' ); | |
| 1642 | - echo esc_html( $this->menu_item_loop_current_term->name ); // @todo tax filter | |
| 1643 | - $this->menu_item_loop_close_element( 'menu_title' ); | |
| 1644 | - if ( $this->menu_item_loop_current_term->description ) : | |
| 1645 | - $this->menu_item_loop_open_element( 'menu_description' ); | |
| 1646 | - echo esc_html( $this->menu_item_loop_current_term->description ); // @todo kses, tax filter | |
| 1647 | - $this->menu_item_loop_close_element( 'menu_description' ); | |
| 1648 | - endif; | |
| 1649 | - $this->menu_item_loop_close_element( 'menu_header' ); | |
| 1650 | - } | |
| 1651 | - | |
| 1652 | - /** | |
| 1653 | - * Outputs a Menu Item Markup element opening tag | |
| 1654 | - * | |
| 1655 | - * @param string $field - Menu Item Markup settings field. | |
| 1656 | - * | |
| 1657 | - * @return void | |
| 1658 | - */ | |
| 1659 | - public function menu_item_loop_open_element( $field ) { | |
| 1660 | - $markup = $this->get_menu_item_loop_markup(); | |
| 1661 | 737 | /** |
| 1662 | - * Filter a menu item's element opening tag. | |
| 738 | + * Outputs a Menu Item Markup element opening tag | |
| 1663 | 739 | * |
| 1664 | - * @module custom-content-types | |
| 740 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 1665 | 741 | * |
| 1666 | - * @since 4.4.0 | |
| 742 | + * @param string $field - Menu Item Markup settings field. | |
| 1667 | 743 | * |
| 1668 | - * @param string $tag Menu item's element opening tag. | |
| 1669 | - * @param string $field Menu Item Markup settings field. | |
| 1670 | - * @param array $markup Array of markup elements for the menu item. | |
| 1671 | - * @param false|object $term Taxonomy term for current menu item. | |
| 744 | + * @return void | |
| 1672 | 745 | */ |
| 1673 | - echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- it's escaped in menu_item_loop_class. | |
| 1674 | - 'jetpack_nova_menu_item_loop_open_element', | |
| 1675 | - '<' . tag_escape( $markup[ "{$field}_tag" ] ) . $this->menu_item_loop_class( $markup[ "{$field}_class" ] ) . ">\n", | |
| 1676 | - $field, | |
| 1677 | - $markup, | |
| 1678 | - $this->menu_item_loop_current_term | |
| 1679 | - ); | |
| 1680 | - } | |
| 746 | + public function menu_item_loop_open_element( $field ) { | |
| 747 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 748 | + $this->new_instance->menu_item_loop_open_element( $field ); | |
| 749 | + } | |
| 1681 | 750 | |
| 1682 | - /** | |
| 1683 | - * Outputs a Menu Item Markup element closing tag | |
| 1684 | - * | |
| 1685 | - * @param string $field - Menu Item Markup settings field. | |
| 1686 | - * | |
| 1687 | - * @return void | |
| 1688 | - */ | |
| 1689 | - public function menu_item_loop_close_element( $field ) { | |
| 1690 | - $markup = $this->get_menu_item_loop_markup(); | |
| 1691 | 751 | /** |
| 1692 | - * Filter a menu item's element closing tag. | |
| 752 | + * Outputs a Menu Item Markup element closing tag | |
| 1693 | 753 | * |
| 1694 | - * @module custom-content-types | |
| 754 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 1695 | 755 | * |
| 1696 | - * @since 4.4.0 | |
| 756 | + * @param string $field - Menu Item Markup settings field. | |
| 1697 | 757 | * |
| 1698 | - * @param string $tag Menu item's element closing tag. | |
| 1699 | - * @param string $field Menu Item Markup settings field. | |
| 1700 | - * @param array $markup Array of markup elements for the menu item. | |
| 1701 | - * @param false|object $term Taxonomy term for current menu item. | |
| 758 | + * @return void | |
| 1702 | 759 | */ |
| 1703 | - echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- tag_escape is used. | |
| 1704 | - 'jetpack_nova_menu_item_loop_close_element', | |
| 1705 | - '</' . tag_escape( $markup[ "{$field}_tag" ] ) . ">\n", | |
| 1706 | - $field, | |
| 1707 | - $markup, | |
| 1708 | - $this->menu_item_loop_current_term | |
| 1709 | - ); | |
| 1710 | - } | |
| 1711 | - | |
| 1712 | - /** | |
| 1713 | - * Returns a Menu Item Markup element's class attribute. | |
| 1714 | - * | |
| 1715 | - * @param string $class Class name. | |
| 1716 | - * | |
| 1717 | - * @return string HTML class attribute with leading whitespace. | |
| 1718 | - */ | |
| 1719 | - public function menu_item_loop_class( $class ) { | |
| 1720 | - if ( ! $class ) { | |
| 1721 | - return ''; | |
| 760 | + public function menu_item_loop_close_element( $field ) { | |
| 761 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 762 | + $this->new_instance->menu_item_loop_close_element( $field ); | |
| 1722 | 763 | } |
| 1723 | 764 | |
| 1724 | 765 | /** |
| 1725 | - * Filter a menu Item Markup element's class attribute. | |
| 766 | + * Returns a Menu Item Markup element's class attribute. | |
| 1726 | 767 | * |
| 1727 | - * @module custom-content-types | |
| 768 | + * @deprecated 14.3 Moved to Classic Theme Helper package. | |
| 1728 | 769 | * |
| 1729 | - * @since 4.4.0 | |
| 770 | + * @param string $class Class name. | |
| 1730 | 771 | * |
| 1731 | - * @param string $tag Menu Item Markup element's class attribute. | |
| 1732 | - * @param string $class Menu Item Class name. | |
| 1733 | - * @param false|object $term Taxonomy term for current menu item. | |
| 772 | + * @return string HTML class attribute with leading whitespace. | |
| 1734 | 773 | */ |
| 1735 | - return apply_filters( | |
| 1736 | - 'jetpack_nova_menu_item_loop_class', | |
| 1737 | - ' class="' . esc_attr( $class ) . '"', | |
| 1738 | - $class, | |
| 1739 | - $this->menu_item_loop_current_term | |
| 1740 | - ); | |
| 774 | + public function menu_item_loop_class( $class ) { | |
| 775 | + _deprecated_function( __FUNCTION__, 'jetpack-14.3' ); | |
| 776 | + return $this->new_instance->menu_item_loop_class( $class ); | |
| 777 | + } | |
| 1741 | 778 | } |
| 1742 | 779 | } |
| 1743 | - | |
| 1744 | -add_action( 'init', array( 'Nova_Restaurant', 'init' ) ); | |