PluginProbe
Powerkit – Supercharge your WordPress Site / 2.3.8
Powerkit – Supercharge your WordPress Site v2.3.8
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / post-featured-ui / admin / class-powerkit-post-featured-ui-admin.php

class-powerkit-post-featured-ui-admin.php in Powerkit – Supercharge your WordPress Site 2.3.8, at modules/post-featured-ui/admin/class-powerkit-post-featured-ui-admin.php

106 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The admin-specific functionality of the module.
4 *
5 * @link https://codesupply.co
6 * @since 1.0.0
7 *
8 * @package Powerkit
9 * @subpackage Modules/Admin
10 */
11
12 /**
13 * The admin-specific functionality of the module.
14 */
15 class Powerkit_Post_Featured_UI_Admin extends Powerkit_Module_Admin {
16
17 /**
18 * Initialize
19 */
20 public function initialize() {
21 add_action( 'admin_head', array( $this, 'admin_head' ), 10 );
22
23 $this->register_featured();
24 $this->add_featured_terms();
25 }
26
27 /**
28 * Register custom featured taxonomy
29 */
30 public function register_featured() {
31
32 $labels = array(
33 'name' => esc_html__( 'Featured Locations', 'powerkit' ),
34 'singular_name' => esc_html__( 'Featured Location', 'powerkit' ),
35 'all_items' => esc_html__( 'All Locations', 'powerkit' ),
36 );
37
38 $args = array(
39 'label' => esc_html__( 'Featured Locations', 'powerkit' ),
40 'labels' => apply_filters( 'powerkit_featured_taxonomy_labels', $labels ),
41 'public' => false,
42 'hierarchical' => true,
43 'show_in_rest' => true,
44 'show_ui' => true,
45 'show_in_menu' => false,
46 'show_in_nav_menus' => false,
47 'query_var' => true,
48 'rewrite' => false,
49 'show_admin_column' => true,
50 'show_in_quick_edit' => true,
51 'sort' => true,
52 'capabilities' => array(
53 'manage_terms' => false,
54 'edit_terms' => false,
55 'delete_terms' => false,
56 ),
57 );
58
59 register_taxonomy( 'powerkit_post_featured', array( 'post' ), apply_filters( 'powerkit_featured_taxonomy_args', $args ) );
60 }
61
62 /**
63 * Add default featured terms upon theme activation
64 */
65 public function add_featured_terms() {
66
67 if ( get_option( 'powerkit_featured_terms_added' ) ) {
68
69 // Return if terms have already been added.
70 return;
71
72 } else {
73
74 // Array of Featured Locations.
75 $featured_terms = array(
76 'archive' => esc_html__( 'Post Archive', 'powerkit' ),
77 'slider' => esc_html__( 'Post Slider', 'powerkit' ),
78 'tiles' => esc_html__( 'Post Tiles', 'powerkit' ),
79 'carousel' => esc_html__( 'Post Carousel', 'powerkit' ),
80 'widget' => esc_html__( 'Posts Widget', 'powerkit' ),
81 );
82
83 // Add terms to custom taxonomy Featured Locations.
84 foreach ( apply_filters( 'powerkit_featured_terms', $featured_terms ) as $term => $name ) {
85 if ( ! term_exists( $name, 'powerkit_post_featured' ) ) {
86 wp_insert_term( $name, 'powerkit_post_featured', array( 'slug' => $term ) );
87 }
88 }
89
90 // Set an option, that terms have been added.
91 update_option( 'powerkit_featured_terms_added', true );
92 }
93 }
94
95 /**
96 * Register the stylesheets and JavaScript for the admin area.
97 *
98 * @param string $page Current page.
99 */
100 public function admin_head( $page ) {
101 ?>
102 <style>.column-taxonomy-powerkit_post_featured{ width: 10%; }</style>
103 <?php
104 }
105 }
106