PluginProbe
Essential Widgets / 1.1
Essential Widgets v1.1
3.2.1 3.3 3.2 trunk 1.0.0 1.0.1 1.1 1.2 1.2.1 1.2.2 1.3 1.4 1.4.1 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 1.9 2.0 2.1 2.2 All 31 releases
essential-widgets / admin / class-essential-widgets-admin.php

class-essential-widgets-admin.php in Essential Widgets 1.1, at admin/class-essential-widgets-admin.php

162 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The admin-specific functionality of the plugin.
5 *
6 * @link https://catchplugins.com
7 * @since 1.0.0
8 *
9 * @package Essential_Widgets
10 * @subpackage Essential_Widgets/admin
11 */
12
13 /**
14 * The admin-specific functionality of the plugin.
15 *
16 * Defines the plugin name, version, and two examples hooks for how to
17 * enqueue the admin-specific stylesheet and JavaScript.
18 *
19 * @package Essential_Widgets
20 * @subpackage Essential_Widgets/admin
21 * @author Catch Plugins <info@catchplugins.com>
22 */
23 class Essential_Widgets_Admin {
24
25 /**
26 * The ID of this plugin.
27 *
28 * @since 1.0.0
29 * @access private
30 * @var string $plugin_name The ID of this plugin.
31 */
32 private $plugin_name;
33
34 /**
35 * The version of this plugin.
36 *
37 * @since 1.0.0
38 * @access private
39 * @var string $version The current version of this plugin.
40 */
41 private $version;
42
43 /**
44 * Initialize the class and set its properties.
45 *
46 * @since 1.0.0
47 * @param string $plugin_name The name of this plugin.
48 * @param string $version The version of this plugin.
49 */
50 public function __construct( $plugin_name, $version ) {
51
52 $this->plugin_name = $plugin_name;
53 $this->version = $version;
54
55 }
56
57 /**
58 * Register the stylesheets for the admin area.
59 *
60 * @since 1.0.0
61 */
62 public function enqueue_styles() {
63
64 /**
65 * This function is provided for demonstration purposes only.
66 *
67 * An instance of this class should be passed to the run() function
68 * defined in Essential_Widgets_Loader as all of the hooks are defined
69 * in that particular class.
70 *
71 * The Essential_Widgets_Loader will then create the relationship
72 * between the defined hooks and the functions defined in this
73 * class.
74 */
75
76 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/essential-widgets-admin.css', array(), $this->version, 'all' );
77
78 }
79
80 /**
81 * Register the JavaScript for the admin area.
82 *
83 * @since 1.0.0
84 */
85 public function enqueue_scripts() {
86
87 /**
88 * This function is provided for demonstration purposes only.
89 *
90 * An instance of this class should be passed to the run() function
91 * defined in Essential_Widgets_Loader as all of the hooks are defined
92 * in that particular class.
93 *
94 * The Essential_Widgets_Loader will then create the relationship
95 * between the defined hooks and the functions defined in this
96 * class.
97 */
98
99 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/essential-widgets-admin.js', array( 'jquery' ), $this->version, false );
100
101 }
102
103 /**
104 * Catch Instagram Feed Gallery Widget: action_links
105 * Catch Instagram Feed Gallery Widget Settings Link function callback
106 *
107 * @param arrray $links Link url.
108 *
109 * @param arrray $file File name.
110 */
111 public function action_links( $links, $file ) {
112 if ( $file === $this->plugin_name . '/' . $this->plugin_name . '.php' ) {
113 $settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=essential_widgets' ) ) . '">' . esc_html__( 'Settings', 'essential-widgets' ) . '</a>';
114
115 array_unshift( $links, $settings_link );
116 }
117 return $links;
118 }
119
120 /**
121 * Catch Instagram Feed Gallery Widget: add_plugin_settings_menu
122 * add Catch Instagram Feed Gallery Widget to menu
123 */
124 public function add_plugin_settings_menu() {
125 add_menu_page(
126 esc_html__( 'Essential Widgets', 'essential-widgets' ),
127 esc_html__( 'Essential Widgets', 'essential-widgets' ),
128 'manage_options',
129 'essential_widgets',
130 array( $this, 'settings_page' ),
131 '',
132 '99.01564'
133 );
134 }
135
136 /**
137 * Catch Instagram Feed Gallery Widget: catch_web_tools_settings_page
138 * Catch Instagram Feed Gallery Widget Setting function
139 */
140 public function settings_page() {
141 if ( ! current_user_can( 'manage_options' ) ) {
142 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );
143 }
144
145 require plugin_dir_path( __FILE__ ) . 'partials/essential-widgets-admin-display.php';
146 }
147
148 /**
149 * Catch Instagram Feed Gallery Widget: register_settings
150 * Catch Instagram Feed Gallery Widget Register Settings
151 */
152 public function register_settings() {
153 register_setting(
154 'essential-widgets-group',
155 'essential_widgets_options',
156 array( $this, 'sanitize_callback' )
157 );
158 }
159
160
161 }
162