simple-author-box
Last commit date
core
11 years ago
css
11 years ago
js
11 years ago
lang
11 years ago
template
11 years ago
readme.txt
11 years ago
simple-author-box.php
11 years ago
uninstall.php
11 years ago
simple-author-box.php
454 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Simple Author Box |
| 4 | * Plugin URI: http://wordpress.org/plugins/simple-author-box/ |
| 5 | * Description: Adds a responsive author box with social icons on your posts. |
| 6 | * Version: 1.2 |
| 7 | * Author: Tiguan |
| 8 | * Author URI: http://tiguandesign.com |
| 9 | * License: GPLv2 |
| 10 | */ |
| 11 | |
| 12 | /* Copyright 2014 Tiguan (email : themesupport [at] tiguandesign [dot] com) |
| 13 | |
| 14 | THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY |
| 15 | IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY |
| 16 | THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR |
| 17 | (AT YOUR OPTION) ANY LATER VERSION. |
| 18 | |
| 19 | THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, |
| 20 | BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF |
| 21 | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE |
| 22 | GNU GENERAL PUBLIC LICENSE FOR MORE DETAILS. |
| 23 | |
| 24 | YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE |
| 25 | ALONG WITH THIS PROGRAM; IF NOT, WRITE TO THE FREE SOFTWARE |
| 26 | FOUNDATION, INC., 51 FRANKLIN ST, FIFTH FLOOR, BOSTON, MA 02110-1301 USA |
| 27 | |
| 28 | */ |
| 29 | |
| 30 | |
| 31 | /*---------------------------------------------------------------------------------------------------------- |
| 32 | Main Plugin Class |
| 33 | -----------------------------------------------------------------------------------------------------------*/ |
| 34 | |
| 35 | if( !class_exists( 'Simple_Author_Box' ) ) { |
| 36 | |
| 37 | class Simple_Author_Box { |
| 38 | |
| 39 | /*---------------------------------------------------------------------------------------------------------- |
| 40 | Function Construct |
| 41 | -----------------------------------------------------------------------------------------------------------*/ |
| 42 | |
| 43 | public function __construct() { |
| 44 | |
| 45 | global $options; |
| 46 | |
| 47 | $options = get_option( 'saboxplugin_options', 'checked' ); // retrieve the plugin settings from the options table |
| 48 | define( 'SIMPLE_AUTHOR_BOX_LAST_UPDATE', date_i18n( 'F j, Y', '1407740400' ) ); // Defining plugin last update |
| 49 | define( 'SIMPLE_AUTHOR_BOX_PATH', plugin_dir_path( __FILE__ ) ); // Defining plugin dir path |
| 50 | define( 'SIMPLE_AUTHOR_BOX_DIRNAME', basename( dirname( __FILE__ ) ) ); // Defining plugin dir name |
| 51 | define( 'SIMPLE_AUTHOR_BOX_VERSION', 'v1.2'); // Defining plugin version |
| 52 | define( 'SIMPLE_AUTHOR_BOX', 'Simple Author Box'); // Defining plugin name |
| 53 | define( 'SIMPLE_AUTHOR_BOX_FOOTER', 10 ); |
| 54 | |
| 55 | |
| 56 | add_action( 'admin_init', array( $this, 'saboxplugin_init_settings' ) ); |
| 57 | add_action( 'plugins_loaded', array( $this, 'saboxplugin_translation' ) ); |
| 58 | add_action( 'wp_enqueue_scripts', array( $this, 'saboxplugin_author_box_style' ) ); |
| 59 | add_action( 'wp_enqueue_scripts', array( $this, 'saboxplugin_author_box_font' ) ); |
| 60 | |
| 61 | if ( isset( $options['sab_footer_inline_style'] ) ) { |
| 62 | add_action( 'wp_footer', array( $this, 'saboxplugin_author_box_inline_style' ), SIMPLE_AUTHOR_BOX_FOOTER+3 ); |
| 63 | } else { |
| 64 | add_action( 'wp_head', array( $this, 'saboxplugin_author_box_inline_style' ), 15 ); |
| 65 | } |
| 66 | |
| 67 | add_action( 'admin_enqueue_scripts', array( $this, 'saboxplugin_admin_style' ) ); |
| 68 | add_action( 'admin_enqueue_scripts', array( $this, 'saboxplugin_color_picker' ) ); |
| 69 | add_action( 'admin_enqueue_scripts', array( $this, 'saboxplugin_scripts' ) ); |
| 70 | add_action( 'admin_enqueue_scripts', array( $this, 'saboxplugin_collapsible' ) ); |
| 71 | add_action( 'wp_enqueue_scripts', array( $this, 'saboxplugin_font_awesome_css' ), 999 ); |
| 72 | |
| 73 | add_action( 'admin_menu', array( $this, 'saboxplugin_add_menu' ) ); |
| 74 | |
| 75 | $this->path = plugin_basename( __FILE__ ); |
| 76 | add_filter( "plugin_action_links_$this->path", array( $this, 'saboxplugin_settings_link' ) ); |
| 77 | |
| 78 | if ( !class_exists( 'Sabox_Social_Icons' ) ) { |
| 79 | require_once( SIMPLE_AUTHOR_BOX_PATH . 'core/sabox_social_icons.php' ); |
| 80 | require_once( SIMPLE_AUTHOR_BOX_PATH . 'core/sabox_author_box.php' ); |
| 81 | } |
| 82 | |
| 83 | } |
| 84 | |
| 85 | |
| 86 | /*---------------------------------------------------------------------------------------------------------- |
| 87 | Activation & Deactivation Hooks |
| 88 | -----------------------------------------------------------------------------------------------------------*/ |
| 89 | |
| 90 | public static function sab_activate() { |
| 91 | // nothing to do yet |
| 92 | } |
| 93 | |
| 94 | public static function sab_deactivate() { |
| 95 | // nothing to do yet |
| 96 | } |
| 97 | |
| 98 | |
| 99 | /*---------------------------------------------------------------------------------------------------------- |
| 100 | Load plugin textdomain |
| 101 | -----------------------------------------------------------------------------------------------------------*/ |
| 102 | |
| 103 | public function saboxplugin_translation() { |
| 104 | load_plugin_textdomain( 'saboxplugin', false, SIMPLE_AUTHOR_BOX_DIRNAME . '/lang/' ); |
| 105 | } |
| 106 | |
| 107 | |
| 108 | /*---------------------------------------------------------------------------------------------------------- |
| 109 | Plugin Settings |
| 110 | -----------------------------------------------------------------------------------------------------------*/ |
| 111 | |
| 112 | public function saboxplugin_init_settings() { |
| 113 | register_setting( 'sabox_plugin', 'saboxplugin_options' ); |
| 114 | register_setting( 'sabox_plugin', 'sab_box_margin_top' ); |
| 115 | register_setting( 'sabox_plugin', 'sab_box_margin_bottom' ); |
| 116 | register_setting( 'sabox_plugin', 'sab_box_icon_size' ); |
| 117 | register_setting( 'sabox_plugin', 'sab_box_name_size' ); |
| 118 | register_setting( 'sabox_plugin', 'sab_box_web_size' ); |
| 119 | register_setting( 'sabox_plugin', 'sab_box_name_font' ); |
| 120 | register_setting( 'sabox_plugin', 'sab_box_subset' ); |
| 121 | register_setting( 'sabox_plugin', 'sab_box_desc_font' ); |
| 122 | register_setting( 'sabox_plugin', 'sab_box_web_font' ); |
| 123 | register_setting( 'sabox_plugin', 'sab_box_desc_size' ); |
| 124 | } |
| 125 | |
| 126 | |
| 127 | /*---------------------------------------------------------------------------------------------------------- |
| 128 | Adding the author box main CSS |
| 129 | -----------------------------------------------------------------------------------------------------------*/ |
| 130 | |
| 131 | public function saboxplugin_author_box_style() { |
| 132 | |
| 133 | if( !is_single() and !is_page() and !is_author() and !is_archive() ) { |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | if ( is_rtl() ) { |
| 138 | wp_enqueue_style( 'sab-plugin', plugins_url( '/css/simple-author-box-rtl.min.css', __FILE__ ), false, SIMPLE_AUTHOR_BOX_VERSION ); // to debug rtl style change the url to /css/dev/simple-author-box-rtl.css |
| 139 | } else { |
| 140 | wp_enqueue_style( 'sab-plugin', plugins_url( '/css/simple-author-box.min.css', __FILE__ ), false, SIMPLE_AUTHOR_BOX_VERSION ); // to debug style change the url to /css/dev/simple-author-box.css |
| 141 | |
| 142 | } |
| 143 | |
| 144 | } |
| 145 | |
| 146 | |
| 147 | /*---------------------------------------------------------------------------------------------------------- |
| 148 | Enqueue Google Fonts |
| 149 | -----------------------------------------------------------------------------------------------------------*/ |
| 150 | |
| 151 | public function saboxplugin_author_box_font() { |
| 152 | |
| 153 | if( !is_single() and !is_page() and !is_author() and !is_archive() ) { |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | global $options; |
| 158 | |
| 159 | $sab_protocol = is_ssl() ? 'https' : 'http'; |
| 160 | |
| 161 | if ( get_option( 'sab_box_subset' ) != 'None' ) { |
| 162 | $sab_box_subset = get_option( 'sab_box_subset' ); |
| 163 | $sab_subset = '&subset='.$sab_box_subset; |
| 164 | |
| 165 | } else { |
| 166 | $sab_subset = ''; |
| 167 | } |
| 168 | |
| 169 | $sab_author_font = get_option( 'sab_box_name_font' ); |
| 170 | $sab_desc_font = get_option( 'sab_box_desc_font' ); |
| 171 | $sab_web_font = get_option( 'sab_box_web_font' ); |
| 172 | |
| 173 | if ( get_option( 'sab_box_name_font' ) != 'none' ) { |
| 174 | wp_enqueue_style( 'sab-author-name-font', $sab_protocol . '://fonts.googleapis.com/css?family='.str_replace(' ', '+', $sab_author_font).':400,700,400italic,700italic'.$sab_subset, array(), null ); |
| 175 | } |
| 176 | |
| 177 | if ( get_option( 'sab_box_desc_font' ) != 'none' ) { |
| 178 | wp_enqueue_style( 'sab-author-desc-font', $sab_protocol . '://fonts.googleapis.com/css?family='.str_replace(' ', '+', $sab_desc_font).':400,700,400italic,700italic'.$sab_subset, array(), null ); |
| 179 | } |
| 180 | |
| 181 | if ( isset( $options['sab_web'] ) and get_option( 'sab_box_web_font' ) != 'none' ) { |
| 182 | wp_enqueue_style( 'sab-author-web-font', $sab_protocol . '://fonts.googleapis.com/css?family='.str_replace(' ', '+', $sab_web_font).':400,700,400italic,700italic'.$sab_subset, array(), null ); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | |
| 187 | /*---------------------------------------------------------------------------------------------------------- |
| 188 | Adding the author box dynamic stylesheet generated by plugin options |
| 189 | -----------------------------------------------------------------------------------------------------------*/ |
| 190 | |
| 191 | public function saboxplugin_author_box_inline_style() { |
| 192 | |
| 193 | if( !is_single() and !is_page() and !is_author() and !is_archive() ) { |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | global $options; |
| 198 | |
| 199 | if ( get_option( 'sab_box_margin_top' ) ) { |
| 200 | $sabox_top_margin = get_option( 'sab_box_margin_top' ); |
| 201 | } else { |
| 202 | $sabox_top_margin = 0; |
| 203 | } |
| 204 | |
| 205 | if ( get_option( 'sab_box_margin_bottom' ) ) { |
| 206 | $sabox_bottom_margin = get_option( 'sab_box_margin_bottom' ); |
| 207 | } else { |
| 208 | $sabox_bottom_margin = 0; |
| 209 | } |
| 210 | |
| 211 | if ( get_option( 'sab_box_name_size' ) ) { |
| 212 | $sabox_name_size = get_option( 'sab_box_name_size' ); |
| 213 | } else { |
| 214 | $sabox_name_size = 18; |
| 215 | } |
| 216 | |
| 217 | if ( isset( $options['sab_web'] ) and get_option( 'sab_box_web_size' ) ) { |
| 218 | $sabox_web_size = get_option( 'sab_box_web_size' ); |
| 219 | } else { |
| 220 | $sabox_web_size = 14; |
| 221 | } |
| 222 | |
| 223 | if ( get_option( 'sab_box_desc_size' ) ) { |
| 224 | $sabox_desc_size = get_option( 'sab_box_desc_size' ); |
| 225 | } else { |
| 226 | $sabox_desc_size = 14; |
| 227 | } |
| 228 | |
| 229 | |
| 230 | if ( get_option( 'sab_box_icon_size' ) ) { |
| 231 | $sabox_icon_size = get_option( 'sab_box_icon_size' ); |
| 232 | } else { |
| 233 | $sabox_icon_size = 14; |
| 234 | } |
| 235 | |
| 236 | $style = '<style type="text/css">'; |
| 237 | |
| 238 | // Border color of Simple Author Box |
| 239 | if( isset( $options['sab_box_border'] ) and !empty( $options['sab_box_border'] ) ) { |
| 240 | $style .= '.saboxplugin-wrap {border-color:'. esc_html( $options['sab_box_border'] ) .';}'; |
| 241 | $style .= '.saboxplugin-wrap .saboxplugin-socials {-webkit-box-shadow: 0 0.05em 0 0 '. esc_html( $options['sab_box_border'] ) .' inset; -moz-box-shadow:0 0.05em 0 0 '. esc_html( $options['sab_box_border'] ) .' inset;box-shadow:0 0.05em 0 0 '. esc_html( $options['sab_box_border'] ) .' inset;}'; |
| 242 | } |
| 243 | // Avatar image style |
| 244 | if( isset( $options['sab_avatar_style'] ) ) { |
| 245 | $style .= '.saboxplugin-wrap .saboxplugin-gravatar img {-webkit-border-radius:50%;-moz-border-radius:50%;-ms-border-radius:50%;-o-border-radius:50%;border-radius:50%;}'; |
| 246 | } |
| 247 | // Social icons style |
| 248 | if( isset( $options['sab_colored'] ) and isset( $options['sab_icons_style'] ) ) { |
| 249 | $style .= '.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-color {-webkit-border-radius:50%;-moz-border-radius:50%;-ms-border-radius:50%;-o-border-radius:50%;border-radius:50%;}'; |
| 250 | } |
| 251 | // Long Shadow |
| 252 | if( isset( $options['sab_colored'] ) and !isset( $options['sab_box_long_shadow'] ) ) { |
| 253 | $style .= '.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-color:before {text-shadow: none;}'; |
| 254 | } |
| 255 | // Avatar hover effect |
| 256 | if( isset( $options['sab_avatar_style'] ) and isset( $options['sab_avatar_hover'] ) ) { |
| 257 | $style .= '.saboxplugin-wrap .saboxplugin-gravatar img {-webkit-transition:all .5s ease;-moz-transition:all .5s ease;-o-transition:all .5s ease;transition:all .5s ease;}'; |
| 258 | $style .= '.saboxplugin-wrap .saboxplugin-gravatar img:hover {-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);}'; |
| 259 | } |
| 260 | // Social icons hover effect |
| 261 | if( isset( $options['sab_icons_style'] ) and isset( $options['sab_social_hover'] ) ) { |
| 262 | $style .= '.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-color, .saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-grey {-webkit-transition: all 0.3s ease-in-out;-moz-transition: all 0.3s ease-in-out;-o-transition: all 0.3s ease-in-out;-ms-transition: all 0.3s ease-in-out;transition: all 0.3s ease-in-out;}.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-color:hover,.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-grey:hover {-webkit-transform: rotate(360deg);-moz-transform: rotate(360deg);-o-transform: rotate(360deg);-ms-transform: rotate(360deg);transform: rotate(360deg);}'; |
| 263 | } |
| 264 | // Thin border |
| 265 | if( isset( $options['sab_colored'] ) and !isset( $options['sab_box_thin_border'] ) ) { |
| 266 | $style .= '.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-color {border: medium none !important;}'; |
| 267 | } |
| 268 | // Background color of social icons bar |
| 269 | if( isset( $options['sab_box_icons_back'] ) and !empty( $options['sab_box_icons_back'] ) ) { |
| 270 | $style .= '.saboxplugin-wrap .saboxplugin-socials{background-color:'. esc_html( $options['sab_box_icons_back'] ) .';}'; |
| 271 | } |
| 272 | // Color of social icons (for symbols only): |
| 273 | if( isset( $options['sab_box_icons_color'] ) and !empty( $options['sab_box_icons_color'] ) ) { |
| 274 | $style .= '.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-grey {color:'. esc_html( $options['sab_box_icons_color'] ) .';}'; |
| 275 | } |
| 276 | // Author name color |
| 277 | if( isset( $options['sab_box_author_color'] ) and !empty( $options['sab_box_author_color'] ) ) { |
| 278 | $style .= '.saboxplugin-wrap .saboxplugin-authorname a {color:'. esc_html( $options['sab_box_author_color'] ) .';}'; |
| 279 | } |
| 280 | |
| 281 | // Author web color |
| 282 | if( isset( $options['sab_web'] ) and isset( $options['sab_box_web_color'] ) and !empty( $options['sab_box_web_color'] ) ) { |
| 283 | $style .= '.saboxplugin-wrap .saboxplugin-web a {color:'. esc_html( $options['sab_box_web_color'] ) .';}'; |
| 284 | } |
| 285 | |
| 286 | // Author name font family |
| 287 | if ( get_option( 'sab_box_name_font' ) != 'none' ) { |
| 288 | $author_name_font = get_option( 'sab_box_name_font' ); |
| 289 | $style .= '.saboxplugin-wrap .saboxplugin-authorname {font-family:"'. esc_html( $author_name_font ) .'";}'; |
| 290 | } |
| 291 | |
| 292 | // Author description font family |
| 293 | if ( get_option( 'sab_box_desc_font' ) != 'none' ) { |
| 294 | $author_desc_font = get_option( 'sab_box_desc_font' ); |
| 295 | $style .= '.saboxplugin-wrap .saboxplugin-desc {font-family:'. esc_html( $author_desc_font ) .';}'; |
| 296 | } |
| 297 | |
| 298 | // Author web font family |
| 299 | if ( isset( $options['sab_web'] ) and get_option( 'sab_box_web_font' ) != 'none' ) { |
| 300 | $author_web_font = get_option( 'sab_box_web_font' ); |
| 301 | $style .= '.saboxplugin-wrap .saboxplugin-web {font-family:"'. esc_html( $author_web_font ) .'";}'; |
| 302 | } |
| 303 | |
| 304 | // Author description font style |
| 305 | if( isset( $options['sab_desc_style'] ) ) { |
| 306 | $style .= '.saboxplugin-wrap .saboxplugin-desc {font-style:italic;}'; |
| 307 | } |
| 308 | // Margin top |
| 309 | $style .= '.saboxplugin-wrap {margin-top:'. absint( $sabox_top_margin ) . 'px;}'; |
| 310 | // Margin bottom |
| 311 | $style .= '.saboxplugin-wrap {margin-bottom:'. absint( $sabox_bottom_margin ) . 'px;}'; |
| 312 | // Author name text size |
| 313 | $style .= '.saboxplugin-wrap .saboxplugin-authorname {font-size:'. absint( $sabox_name_size ) . 'px;}'; |
| 314 | // Author description font size |
| 315 | $style .= '.saboxplugin-wrap .saboxplugin-desc {font-size:'. absint( $sabox_desc_size ) . 'px;}'; |
| 316 | // Author website text size |
| 317 | $style .= '.saboxplugin-wrap .saboxplugin-web {font-size:'. absint( $sabox_web_size ) . 'px;}'; |
| 318 | // Icons size |
| 319 | $style .= '.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-color {font-size:'. absint( $sabox_icon_size+3 ) . 'px;}'; |
| 320 | $style .= '.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-color:before {width:'. absint( $sabox_icon_size+$sabox_icon_size ) . 'px; height:'. absint( $sabox_icon_size+$sabox_icon_size ) . 'px; line-height:'. absint( $sabox_icon_size+$sabox_icon_size+1 ) . 'px; }'; |
| 321 | $style .= '.saboxplugin-wrap .saboxplugin-socials .saboxplugin-icon-grey {font-size:'. absint( $sabox_icon_size ) . 'px;}'; |
| 322 | $style .= '</style>'; |
| 323 | |
| 324 | echo $style; |
| 325 | } |
| 326 | |
| 327 | |
| 328 | /*---------------------------------------------------------------------------------------------------------- |
| 329 | Adding admin options stylesheet |
| 330 | -----------------------------------------------------------------------------------------------------------*/ |
| 331 | |
| 332 | public function saboxplugin_admin_style( $hook ) { |
| 333 | |
| 334 | // load stylesheet only on plugin options page |
| 335 | global $saboxplugin_settings_page; |
| 336 | if ( $hook != $saboxplugin_settings_page ) |
| 337 | return; |
| 338 | if ( is_rtl() ) { |
| 339 | wp_enqueue_style( 'saboxplugin-admin-style', plugin_dir_url( __FILE__ ) . 'css/sabox-admin-style-rtl.min.css' ); // to debug admin rtl style change the url to /css/dev/sabox-admin-style-rtl.css |
| 340 | } else { |
| 341 | wp_enqueue_style( 'saboxplugin-admin-style', plugin_dir_url( __FILE__ ) . 'css/sabox-admin-style.min.css' ); // to debug admin style change the url to /css/dev/sabox-admin-style.css |
| 342 | } |
| 343 | wp_enqueue_style( 'jquery-ui', plugin_dir_url( __FILE__ ) . 'css/jquery-ui.min.css' ); |
| 344 | |
| 345 | } |
| 346 | |
| 347 | |
| 348 | /*---------------------------------------------------------------------------------------------------------- |
| 349 | Adding colorpicker to plugin options page |
| 350 | -----------------------------------------------------------------------------------------------------------*/ |
| 351 | |
| 352 | public function saboxplugin_color_picker( $hook_color ) { |
| 353 | // load color picker only on plugin options page |
| 354 | global $saboxplugin_settings_page; |
| 355 | if ( $hook_color != $saboxplugin_settings_page ) |
| 356 | return; |
| 357 | wp_enqueue_style( 'wp-color-picker' ); |
| 358 | wp_enqueue_script( 'sabox-color-js', plugins_url('js/sabox-color-picker.js', __FILE__ ), array( 'wp-color-picker' ), false, true ); |
| 359 | } |
| 360 | |
| 361 | |
| 362 | /*---------------------------------------------------------------------------------------------------------- |
| 363 | Enqueue scripts to plugin options page |
| 364 | -----------------------------------------------------------------------------------------------------------*/ |
| 365 | |
| 366 | public function saboxplugin_scripts( $hook_slide ) { |
| 367 | // load slide only on plugin options page |
| 368 | global $saboxplugin_settings_page; |
| 369 | if ( $hook_slide != $saboxplugin_settings_page ) |
| 370 | return; |
| 371 | wp_enqueue_script( 'jquery-ui-slider' ); |
| 372 | wp_enqueue_script( 'sabox-slide', plugins_url('js/sabox-slide.js', __FILE__ ), array( 'jquery', 'jquery-ui-slider' ), SIMPLE_AUTHOR_BOX_VERSION, true ); |
| 373 | wp_enqueue_script( 'sabox-hide', plugins_url('js/sabox-hide.js', __FILE__ ), array( 'jquery' ), SIMPLE_AUTHOR_BOX_VERSION, true ); |
| 374 | |
| 375 | } |
| 376 | |
| 377 | |
| 378 | /*---------------------------------------------------------------------------------------------------------- |
| 379 | Enqueue scripts to plugin options page for collapsible options |
| 380 | -----------------------------------------------------------------------------------------------------------*/ |
| 381 | |
| 382 | function saboxplugin_collapsible( $sab_suffix ) { |
| 383 | global $saboxplugin_settings_page; |
| 384 | if ( $sab_suffix != $saboxplugin_settings_page ) |
| 385 | return; |
| 386 | wp_enqueue_script( 'postbox' ); |
| 387 | wp_enqueue_script( 'postbox-edit', plugins_url('js/postbox-edit.js', __FILE__ ), array( 'jquery', 'postbox' ) ); |
| 388 | } |
| 389 | |
| 390 | |
| 391 | /*---------------------------------------------------------------------------------------------------------- |
| 392 | Enqueue Font Awesome in front-end |
| 393 | -----------------------------------------------------------------------------------------------------------*/ |
| 394 | |
| 395 | public function saboxplugin_font_awesome_css() { |
| 396 | global $options; |
| 397 | if ( !isset( $options['sab_load_fa'] ) ) { |
| 398 | wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' ); |
| 399 | } |
| 400 | |
| 401 | } |
| 402 | |
| 403 | |
| 404 | /*---------------------------------------------------------------------------------------------------------- |
| 405 | Adding settings link on plugins page |
| 406 | -----------------------------------------------------------------------------------------------------------*/ |
| 407 | |
| 408 | public function saboxplugin_settings_link( $links ) { |
| 409 | |
| 410 | $settings_link = '<a href="options-general.php?page=simple-author-box-options">Settings</a>'; |
| 411 | array_unshift( $links, $settings_link ); |
| 412 | return $links; |
| 413 | |
| 414 | } |
| 415 | |
| 416 | |
| 417 | /*---------------------------------------------------------------------------------------------------------- |
| 418 | Adding settings link on plugins page |
| 419 | -----------------------------------------------------------------------------------------------------------*/ |
| 420 | |
| 421 | public function saboxplugin_add_menu() { |
| 422 | |
| 423 | // Add a page to manage the plugin's settings |
| 424 | global $saboxplugin_settings_page; |
| 425 | $saboxplugin_settings_page = add_options_page( 'Simple Author Box', 'Simple Author Box', 'manage_options', 'simple-author-box-options', array( $this, 'saboxplugin_settings_page' ) ); |
| 426 | |
| 427 | } |
| 428 | |
| 429 | |
| 430 | /*---------------------------------------------------------------------------------------------------------- |
| 431 | Busted if user can't manage options |
| 432 | -----------------------------------------------------------------------------------------------------------*/ |
| 433 | |
| 434 | public function saboxplugin_settings_page() { |
| 435 | |
| 436 | if( !current_user_can( 'manage_options' ) ) { |
| 437 | wp_die(__( 'You do not have sufficient permissions to access this page.' ) ); |
| 438 | } |
| 439 | include( SIMPLE_AUTHOR_BOX_PATH . 'core/sabox-fonts.php' ); |
| 440 | require_once( SIMPLE_AUTHOR_BOX_PATH . 'template/options.php' ); |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | |
| 446 | if( class_exists( 'Simple_Author_Box' ) ) { |
| 447 | |
| 448 | // Installation and uninstallation hooks |
| 449 | register_activation_hook( __FILE__, array( 'Simple_Author_Box', 'sab_activate' ) ); |
| 450 | register_deactivation_hook( __FILE__, array( 'Simple_Author_Box', 'sab_deactivate' ) ); |
| 451 | |
| 452 | // Initialise Class |
| 453 | $simple_author_box_by_tiguan = new Simple_Author_Box(); |
| 454 | } |