variables = $variables; $this->categories = $categories; $this->builtins = $builtins; } public function register() { add_action( 'admin_menu', array( $this, 'menu' ), 11 ); add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); } public function menu() { $this->hook = add_submenu_page( 'glovario', __( 'Site Variables Overview', 'glovario' ), __( 'Overview', 'glovario' ), 'manage_options', 'glovario-overview', array( $this, 'page' ) ); } public function assets( $hook ) { if ( $this->hook === $hook ) { $css_modified = filemtime( GLOVARIO_PATH . 'assets/admin.css' ); $js_modified = filemtime( GLOVARIO_PATH . 'assets/admin.js' ); wp_enqueue_style( 'glovario-admin', GLOVARIO_URL . 'assets/admin.css', array(), GLOVARIO_VERSION . ( $css_modified ? '-' . $css_modified : '' ) ); wp_enqueue_script( 'glovario-admin', GLOVARIO_URL . 'assets/admin.js', array(), GLOVARIO_VERSION . ( $js_modified ? '-' . $js_modified : '' ), true ); } } public function page() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to view the Site Variables overview.', 'glovario' ), 403 ); } $metrics = array( array( 'label' => __( 'User variables', 'glovario' ), 'value' => $this->variables->count(), ), array( 'label' => __( 'Categories', 'glovario' ), 'value' => $this->categories->count(), ), array( 'label' => __( 'Built-in variables', 'glovario' ), 'value' => count( $this->builtins->all() ), ), ); $recent = $this->variables->all( array( 'number' => 5, 'orderby' => 'updated_at', 'order' => 'DESC', ) ); ?>

notice(); ?>

categories->all(); ?>

'glovario', 'action' => 'edit', 'id' => $variable['id'], ), admin_url( 'admin.php' ) ); ?>

%2$s

', esc_attr( $notice['type'] ), esc_html( $notice['message'] ) ); } } }