Tan-007 /
myslideshow
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * The admin-specific functionality of the plugin. |
||
| 5 | * |
||
| 6 | * @link rahicodes.wordpress.com |
||
| 7 | * @since 1.0.0 |
||
| 8 | * |
||
| 9 | * @package Myslideshow |
||
| 10 | * @subpackage Myslideshow/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 Myslideshow |
||
| 20 | * @subpackage Myslideshow/admin |
||
| 21 | * @author Rahi Prajapati <[email protected]> |
||
| 22 | */ |
||
| 23 | class Myslideshow_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 | |||
| 53 | $this->plugin_name = $plugin_name; |
||
| 54 | $this->version = $version; |
||
| 55 | |||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Register the stylesheets for the admin area. |
||
| 60 | * |
||
| 61 | * @since 1.0.0 |
||
| 62 | */ |
||
| 63 | public function enqueue_styles() { |
||
| 64 | |||
| 65 | /** |
||
| 66 | * This function is provided for demonstration purposes only. |
||
| 67 | * |
||
| 68 | * An instance of this class should be passed to the run() function |
||
| 69 | * defined in Myslideshow_Loader as all of the hooks are defined |
||
| 70 | * in that particular class. |
||
| 71 | * |
||
| 72 | * The Myslideshow_Loader will then create the relationship |
||
| 73 | * between the defined hooks and the functions defined in this |
||
| 74 | * class. |
||
| 75 | */ |
||
| 76 | |||
| 77 | wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/myslideshow-admin.css', array(), $this->version, 'all'); |
||
| 78 | |||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Register the JavaScript for the admin area. |
||
| 83 | * |
||
| 84 | * @since 1.0.0 |
||
| 85 | */ |
||
| 86 | public function enqueue_scripts() { |
||
| 87 | |||
| 88 | /** |
||
| 89 | * This function is provided for demonstration purposes only. |
||
| 90 | * |
||
| 91 | * An instance of this class should be passed to the run() function |
||
| 92 | * defined in Myslideshow_Loader as all of the hooks are defined |
||
| 93 | * in that particular class. |
||
| 94 | * |
||
| 95 | * The Myslideshow_Loader will then create the relationship |
||
| 96 | * between the defined hooks and the functions defined in this |
||
| 97 | * class. |
||
| 98 | */ |
||
| 99 | |||
| 100 | wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/myslideshow-admin.js', array('jquery'), $this->version, false); |
||
| 101 | |||
| 102 | } |
||
| 103 | |||
| 104 | /********* CUSTOM FUNCTIONS START HERE ***********/ |
||
| 105 | /** |
||
| 106 | * Function for our settings page |
||
| 107 | * |
||
| 108 | * @since 1.0.1 |
||
| 109 | */ |
||
| 110 | public function mss_settings_page() { |
||
| 111 | |||
| 112 | /** |
||
| 113 | * for adding the settings page under "Settings" menu |
||
| 114 | * add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function ); |
||
| 115 | */ |
||
| 116 | |||
| 117 | /** |
||
| 118 | * for adding the page under root menu |
||
| 119 | * add_menu_page( string $page_title, string $menu_title, string $capability, |
||
| 120 | * string $menu_slug, callable $function = '', string $icon_url = '', int $position = null ) |
||
| 121 | */ |
||
| 122 | |||
| 123 | //'book_render_settings_page' function in : .../admin/partials/rahi_wpbook-admin-display.php |
||
| 124 | add_menu_page( __( 'My Slide Show Settings', 'myslideshow' ), __( 'Slideshow Settings', 'myslideshow' ), 'manage_options', 'slideshow-settings', 'mss_render_settings_page', |
||
| 125 | 'dashicons-chart-pie', '59' ); |
||
| 126 | } |
||
| 127 | |||
| 128 | /** |
||
| 129 | * Function for registering settings |
||
| 130 | * |
||
| 131 | * @since 1.0.1 |
||
| 132 | */ |
||
| 133 | function mss_register_settings() { |
||
|
0 ignored issues
–
show
|
|||
| 134 | register_setting( 'mss-settings-group', 'mss_settings' ); |
||
| 135 | } |
||
| 136 | |||
| 137 | /** |
||
| 138 | * Function for adding short code |
||
| 139 | * |
||
| 140 | * @since 1.0.2 |
||
| 141 | */ |
||
| 142 | public function mss_add_shortcode( ) { |
||
| 143 | |||
| 144 | // function in : .../admin/partials/myslideshow-admin-display.php |
||
| 145 | return render_mss_shortcode( ); |
||
| 146 | |||
| 147 | } |
||
| 148 | |||
| 149 | function mss_register_shortcodes() { |
||
|
0 ignored issues
–
show
|
|||
| 150 | add_shortcode( 'slideshow', array( $this, 'mss_add_shortcode' ) ); |
||
| 151 | } |
||
| 152 | |||
| 153 | } |
||
| 154 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.