← Back
Editing: class-addons.php
<?php namespace Uncanny_Automator; /** * Class Addons * Handles the Automator addons admin page functionality * * @package Uncanny_Automator */ class Addons { /** * The page identifier used in URLs and hooks * * @var string */ public $page_id = 'addons'; /** * Initialize the class and set up hooks * * @return void */ public function __construct() { add_action( 'admin_menu', array( $this, 'addons_menu' ) ); } /** * Adds the Addons submenu page to the WordPress admin menu * * @return void */ public function addons_menu() { $parent_slug = 'edit.php?post_type=uo-recipe'; $page_title = esc_attr__( 'Addons', 'uncanny-automator' ); $menu_title = esc_attr__( 'Addons', 'uncanny-automator' ); $capability = automator_get_capability(); $menu_slug = 'uncanny-automator-' . $this->page_id; $function = array( $this, 'addons_view' ); $position = 9; add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function, $position ); } /** * Renders the addons admin page view * * @return void */ public function addons_view() { include_once 'view-addons.php'; } /** * Get the addon admin URL. * * @param array $args The query arguments. * * @return string The addon admin URL. */ public static function get_addon_admin_url( $args = array() ) { $defaults = array( 'post_type' => AUTOMATOR_POST_TYPE_RECIPE, 'page' => 'uncanny-automator-addons', ); $args = wp_parse_args( $args, $defaults ); return add_query_arg( $args, admin_url( 'edit.php' ) ); } /** * Get the addon settings page URL if available. * * @param mixed ( int|array ) $addon * * @return mixed ( string|int ) */ public static function get_addon_settings_url( $addon, $args = array() ) { $tab = is_string( $addon ) ? $addon : false; if ( ! $tab && is_array( $addon ) ) { $tab = isset( $addon['tab'] ) ? $addon['tab'] : false; } if ( empty( $tab ) ) { return false; } $url = Admin_Settings_Addons::utility_get_addons_page_link( $tab ); if ( ! empty( $args ) && is_array( $args ) ) { $url = add_query_arg( $args, $url ); } return $url; } }
Save File
Cancel