ocean-extra
Last commit date
assets
6 years ago
includes
6 years ago
languages
8 years ago
sass
6 years ago
index.php
9 years ago
ocean-extra.php
6 years ago
readme.txt
6 years ago
wpml-config.xml
7 years ago
ocean-extra.php
658 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Ocean Extra |
| 4 | * Plugin URI: https://oceanwp.org/extension/ocean-extra/ |
| 5 | * Description: Add extra features like widgets, metaboxes, import/export and a panel to activate the premium extensions. |
| 6 | * Version: 1.5.17 |
| 7 | * Author: OceanWP |
| 8 | * Author URI: https://oceanwp.org/ |
| 9 | * Requires at least: 4.5.0 |
| 10 | * Tested up to: 5.2 |
| 11 | * |
| 12 | * Text Domain: ocean-extra |
| 13 | * Domain Path: /languages/ |
| 14 | * |
| 15 | * @package Ocean_Extra |
| 16 | * @category Core |
| 17 | * @author OceanWP |
| 18 | */ |
| 19 | |
| 20 | // Exit if accessed directly |
| 21 | if ( ! defined( 'ABSPATH' ) ) { |
| 22 | exit; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Returns the main instance of Ocean_Extra to prevent the need to use globals. |
| 27 | * |
| 28 | * @since 1.0.0 |
| 29 | * @return object Ocean_Extra |
| 30 | */ |
| 31 | function Ocean_Extra() { |
| 32 | return Ocean_Extra::instance(); |
| 33 | } // End Ocean_Extra() |
| 34 | |
| 35 | Ocean_Extra(); |
| 36 | |
| 37 | /** |
| 38 | * Main Ocean_Extra Class |
| 39 | * |
| 40 | * @class Ocean_Extra |
| 41 | * @version 1.0.0 |
| 42 | * @since 1.0.0 |
| 43 | * @package Ocean_Extra |
| 44 | */ |
| 45 | final class Ocean_Extra { |
| 46 | /** |
| 47 | * Ocean_Extra The single instance of Ocean_Extra. |
| 48 | * @var object |
| 49 | * @access private |
| 50 | * @since 1.0.0 |
| 51 | */ |
| 52 | private static $_instance = null; |
| 53 | |
| 54 | /** |
| 55 | * The token. |
| 56 | * @var string |
| 57 | * @access public |
| 58 | * @since 1.0.0 |
| 59 | */ |
| 60 | public $token; |
| 61 | |
| 62 | /** |
| 63 | * The version number. |
| 64 | * @var string |
| 65 | * @access public |
| 66 | * @since 1.0.0 |
| 67 | */ |
| 68 | public $version; |
| 69 | |
| 70 | // Admin - Start |
| 71 | /** |
| 72 | * The admin object. |
| 73 | * @var object |
| 74 | * @access public |
| 75 | * @since 1.0.0 |
| 76 | */ |
| 77 | public $admin; |
| 78 | |
| 79 | /** |
| 80 | * Constructor function. |
| 81 | * @access public |
| 82 | * @since 1.0.0 |
| 83 | * @return void |
| 84 | */ |
| 85 | public function __construct( $widget_areas = array() ) { |
| 86 | $this->token = 'ocean-extra'; |
| 87 | $this->plugin_url = plugin_dir_url( __FILE__ ); |
| 88 | $this->plugin_path = plugin_dir_path( __FILE__ ); |
| 89 | $this->version = '1.5.17'; |
| 90 | |
| 91 | define( 'OE_URL', $this->plugin_url ); |
| 92 | define( 'OE_PATH', $this->plugin_path ); |
| 93 | define( 'OE_VERSION', $this->version ); |
| 94 | define( 'OE_FILE_PATH', __FILE__ ); |
| 95 | define( 'OE_ADMIN_PANEL_HOOK_PREFIX', 'theme-panel_page_oceanwp-panel' ); |
| 96 | |
| 97 | // WPForms partner ID |
| 98 | add_filter( 'wpforms_upgrade_link', array( $this, 'wpforms_upgrade_link' ) ); |
| 99 | |
| 100 | // WooCommerce Wishlist partner ID |
| 101 | if ( class_exists( 'TInvWL_Wishlist' ) ) { |
| 102 | define( 'TINVWL_PARTNER', 'oceanwporg' ); |
| 103 | define( 'TINVWL_CAMPAIGN', 'oceanwp_theme' ); |
| 104 | } |
| 105 | |
| 106 | // WooCommerce Variation Swatches partner ID |
| 107 | add_filter( 'gwp_affiliate_id', array( $this, 'gwp_affiliate_id' ) ); |
| 108 | |
| 109 | register_activation_hook( __FILE__, array( $this, 'install' ) ); |
| 110 | |
| 111 | add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
| 112 | |
| 113 | // Setup all the things |
| 114 | add_action( 'init', array( $this, 'setup' ) ); |
| 115 | |
| 116 | // Menu icons |
| 117 | $theme = wp_get_theme(); |
| 118 | if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) { |
| 119 | require_once( OE_PATH .'/includes/panel/theme-panel.php' ); |
| 120 | require_once( OE_PATH .'/includes/panel/integrations-tab.php' ); |
| 121 | require_once( OE_PATH .'/includes/panel/library.php' ); |
| 122 | require_once( OE_PATH .'/includes/panel/library-shortcode.php' ); |
| 123 | require_once( OE_PATH .'/includes/panel/updater.php' ); |
| 124 | require_once( OE_PATH .'/includes/menu-icons/menu-icons.php' ); |
| 125 | require_once( OE_PATH .'/includes/wizard/wizard.php' ); |
| 126 | |
| 127 | // Outputs custom JS to the footer |
| 128 | add_action( 'wp_footer', array( $this, 'custom_js' ), 9999 ); |
| 129 | |
| 130 | // Register Custom JS file |
| 131 | add_action( 'init', array( $this, 'register_custom_js' ) ); |
| 132 | |
| 133 | // Move the Custom CSS section into the Custom CSS/JS section |
| 134 | add_action( 'customize_register', array( $this, 'customize_register' ), 11 ); |
| 135 | |
| 136 | // Remove customizer unnecessary sections |
| 137 | add_action( 'customize_register', array( $this, 'remove_customize_sections' ), 11 ); |
| 138 | |
| 139 | // Load custom widgets |
| 140 | add_action( 'widgets_init', array( $this, 'custom_widgets' ), 10 ); |
| 141 | |
| 142 | // Add meta tags |
| 143 | add_filter( 'wp_head', array( $this, 'meta_tags' ), 1 ); |
| 144 | } |
| 145 | |
| 146 | // Allow shortcodes in text widgets |
| 147 | add_filter( 'widget_text', 'do_shortcode' ); |
| 148 | |
| 149 | // Allow for the use of shortcodes in the WordPress excerpt |
| 150 | add_filter( 'the_excerpt', 'shortcode_unautop' ); |
| 151 | add_filter( 'the_excerpt', 'do_shortcode' ); |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Main Ocean_Extra Instance |
| 156 | * |
| 157 | * Ensures only one instance of Ocean_Extra is loaded or can be loaded. |
| 158 | * |
| 159 | * @since 1.0.0 |
| 160 | * @static |
| 161 | * @see Ocean_Extra() |
| 162 | * @return Main Ocean_Extra instance |
| 163 | */ |
| 164 | public static function instance() { |
| 165 | if ( is_null( self::$_instance ) ) |
| 166 | self::$_instance = new self(); |
| 167 | return self::$_instance; |
| 168 | } // End instance() |
| 169 | |
| 170 | /** |
| 171 | * WPForms partner ID |
| 172 | * |
| 173 | * @since 1.0.0 |
| 174 | */ |
| 175 | public function wpforms_upgrade_link() { |
| 176 | $url = 'https://wpforms.com/lite-upgrade/?discount=LITEUPGRADE&utm_source=WordPress&utm_medium=' . sanitize_key( apply_filters( 'wpforms_upgrade_link_medium', 'link' ) ) . '&utm_campaign=liteplugin'; |
| 177 | |
| 178 | // Build final URL |
| 179 | $final_url = sprintf( 'http://www.shareasale.com/r.cfm?B=837827&U=%s&M=64312&urllink=%s', '1591020', $url ); |
| 180 | |
| 181 | // Return URL. |
| 182 | return esc_url( $final_url ); |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * WooCommerce Variation Swatches partner ID |
| 187 | * |
| 188 | * @since 1.0.0 |
| 189 | */ |
| 190 | public function gwp_affiliate_id() { |
| 191 | |
| 192 | // Return if the plugin is not active |
| 193 | if ( ! class_exists( 'Woo_Variation_Swatches' ) ) { |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | return 69; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Load the localisation file. |
| 202 | * @access public |
| 203 | * @since 1.0.0 |
| 204 | * @return void |
| 205 | */ |
| 206 | public function load_plugin_textdomain() { |
| 207 | load_plugin_textdomain( 'ocean-extra', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Cloning is forbidden. |
| 212 | * |
| 213 | * @since 1.0.0 |
| 214 | */ |
| 215 | public function __clone() { |
| 216 | _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?' ), '1.0.0' ); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Unserializing instances of this class is forbidden. |
| 221 | * |
| 222 | * @since 1.0.0 |
| 223 | */ |
| 224 | public function __wakeup() { |
| 225 | _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?' ), '1.0.0' ); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Installation. |
| 230 | * Runs on activation. Logs the version number and assigns a notice message to a WordPress option. |
| 231 | * @access public |
| 232 | * @since 1.0.0 |
| 233 | * @return void |
| 234 | */ |
| 235 | public function install() { |
| 236 | $this->_log_version_number(); |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * Log the plugin version number. |
| 241 | * @access private |
| 242 | * @since 1.0.0 |
| 243 | * @return void |
| 244 | */ |
| 245 | private function _log_version_number() { |
| 246 | // Log the version number. |
| 247 | update_option( $this->token . '-version', $this->version ); |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * All theme functions hook into the oceanwp_footer_js filter for this function. |
| 252 | * |
| 253 | * @since 1.3.8 |
| 254 | */ |
| 255 | public static function custom_js( $output = NULL ) { |
| 256 | |
| 257 | // Add filter for adding custom js via other functions |
| 258 | $output = apply_filters( 'ocean_footer_js', $output ); |
| 259 | |
| 260 | // Minify and output JS in the wp_footer |
| 261 | if ( ! empty( $output ) ) { ?> |
| 262 | |
| 263 | <script type="text/javascript"> |
| 264 | |
| 265 | /* OceanWP JS */ |
| 266 | <?php echo Ocean_Extra_JSMin::minify( $output ); ?> |
| 267 | |
| 268 | </script> |
| 269 | |
| 270 | <?php |
| 271 | } |
| 272 | |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Adds customizer options |
| 277 | * |
| 278 | * @since 1.3.8 |
| 279 | */ |
| 280 | public function register_custom_js() { |
| 281 | |
| 282 | // Var |
| 283 | $dir = OE_PATH .'/includes/'; |
| 284 | |
| 285 | // File |
| 286 | if ( Ocean_Extra_Theme_Panel::get_setting( 'oe_custom_code_panel' ) ) { |
| 287 | require_once( $dir . 'custom-code.php' ); |
| 288 | } |
| 289 | |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * Move the Custom CSS section into the Custom CSS/JS section |
| 294 | * |
| 295 | * @since 1.3.8 |
| 296 | */ |
| 297 | public static function customize_register( $wp_customize ) { |
| 298 | |
| 299 | // Move custom css setting |
| 300 | $wp_customize->get_control( 'custom_css' )->section = 'ocean_custom_code_panel'; |
| 301 | |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Remove customizer unnecessary sections |
| 306 | * |
| 307 | * @since 1.0.0 |
| 308 | */ |
| 309 | public static function remove_customize_sections( $wp_customize ) { |
| 310 | |
| 311 | // Remove core sections |
| 312 | $wp_customize->remove_section( 'colors' ); |
| 313 | $wp_customize->remove_section( 'themes' ); |
| 314 | $wp_customize->remove_section( 'background_image' ); |
| 315 | |
| 316 | // Remove core controls |
| 317 | $wp_customize->remove_control( 'header_textcolor' ); |
| 318 | $wp_customize->remove_control( 'background_color' ); |
| 319 | $wp_customize->remove_control( 'background_image' ); |
| 320 | $wp_customize->remove_control( 'display_header_text' ); |
| 321 | |
| 322 | // Remove default settings |
| 323 | $wp_customize->remove_setting( 'background_color' ); |
| 324 | $wp_customize->remove_setting( 'background_image' ); |
| 325 | |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * Setup all the things. |
| 330 | * Only executes if OceanWP or a child theme using OceanWP as a parent is active and the extension specific filter returns true. |
| 331 | * @return void |
| 332 | */ |
| 333 | public function setup() { |
| 334 | $theme = wp_get_theme(); |
| 335 | |
| 336 | if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) { |
| 337 | require_once( OE_PATH .'/includes/metabox/butterbean/butterbean.php' ); |
| 338 | require_once( OE_PATH .'/includes/metabox/metabox.php' ); |
| 339 | require_once( OE_PATH .'/includes/metabox/shortcodes.php' ); |
| 340 | require_once( OE_PATH .'/includes/metabox/gallery-metabox/gallery-metabox.php' ); |
| 341 | require_once( OE_PATH .'/includes/shortcodes/shortcodes.php' ); |
| 342 | require_once( OE_PATH .'/includes/image-resizer.php' ); |
| 343 | require_once( OE_PATH .'/includes/jsmin.php' ); |
| 344 | require_once( OE_PATH .'/includes/panel/notice.php' ); |
| 345 | require_once( OE_PATH .'/includes/walker.php' ); |
| 346 | require_once( OE_PATH .'/includes/dashboard.php' ); |
| 347 | require_once( OE_PATH .'/includes/panel/demos.php' ); |
| 348 | |
| 349 | add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ), 999 ); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Include flickr widget class |
| 355 | * |
| 356 | * @since 1.0.0 |
| 357 | */ |
| 358 | public static function custom_widgets() { |
| 359 | |
| 360 | if ( ! version_compare( PHP_VERSION, '5.6', '>=' ) ) { |
| 361 | return; |
| 362 | } |
| 363 | |
| 364 | // Define array of custom widgets for the theme |
| 365 | $widgets = apply_filters( 'ocean_custom_widgets', array( |
| 366 | 'about-me', |
| 367 | 'contact-info', |
| 368 | 'custom-links', |
| 369 | 'custom-menu', |
| 370 | 'facebook', |
| 371 | 'flickr', |
| 372 | 'instagram', |
| 373 | 'mailchimp', |
| 374 | 'recent-posts', |
| 375 | 'social', |
| 376 | 'social-share', |
| 377 | 'tags', |
| 378 | 'twitter', |
| 379 | 'video', |
| 380 | 'custom-header-logo', |
| 381 | 'custom-header-nav', |
| 382 | ) ); |
| 383 | |
| 384 | // Loop through widgets and load their files |
| 385 | if ( $widgets && is_array( $widgets ) ) { |
| 386 | foreach ( $widgets as $widget ) { |
| 387 | $file = OE_PATH .'/includes/widgets/' . $widget .'.php'; |
| 388 | if ( file_exists ( $file ) ) { |
| 389 | require_once( $file ); |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Add meta tags |
| 398 | * |
| 399 | * @since 1.5.1 |
| 400 | */ |
| 401 | public static function meta_tags() { |
| 402 | |
| 403 | // Return if disabled or if Yoast SEO enabled as they have their own meta tags |
| 404 | if ( false == get_theme_mod( 'ocean_open_graph', false ) |
| 405 | || defined( 'WPSEO_VERSION' ) |
| 406 | || defined( 'RANK_MATH_FILE' ) ) { |
| 407 | return; |
| 408 | } |
| 409 | |
| 410 | // Facebook URL |
| 411 | $facebook_url = get_theme_mod( 'ocean_facebook_page_url' ); |
| 412 | |
| 413 | // Disable Jetpack's Open Graph tags |
| 414 | add_filter( 'jetpack_enable_opengraph', '__return_false', 99 ); |
| 415 | add_filter( 'jetpack_enable_open_graph', '__return_false', 99 ); |
| 416 | add_filter( 'jetpack_disable_twitter_cards', '__return_true', 99 ); |
| 417 | |
| 418 | // Type |
| 419 | if ( is_front_page() || is_home() ) { |
| 420 | $type = 'website'; |
| 421 | } else if ( is_singular() ) { |
| 422 | $type = 'article'; |
| 423 | } else { |
| 424 | // We use "object" for archives etc. as article doesn't apply there. |
| 425 | $type = 'object'; |
| 426 | } |
| 427 | |
| 428 | // Title |
| 429 | if ( is_singular() ) { |
| 430 | $title = get_the_title(); |
| 431 | } else { |
| 432 | $title = oceanwp_title(); |
| 433 | } |
| 434 | |
| 435 | // Description |
| 436 | if ( is_category() || is_tag() || is_tax() ) { |
| 437 | $description = strip_shortcodes( wp_strip_all_tags( term_description() ) ); |
| 438 | } else { |
| 439 | $description = html_entity_decode( htmlspecialchars_decode( oceanwp_excerpt( 40 ) ) ); |
| 440 | } |
| 441 | |
| 442 | // Image |
| 443 | $image = ''; |
| 444 | $has_img = false; |
| 445 | if ( OCEANWP_WOOCOMMERCE_ACTIVE |
| 446 | && is_product_category() ) { |
| 447 | global $wp_query; |
| 448 | $cat = $wp_query->get_queried_object(); |
| 449 | $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); |
| 450 | $get_image = wp_get_attachment_url( $thumbnail_id ); |
| 451 | if ( $get_image ) { |
| 452 | $image = $get_image; |
| 453 | $has_img = true; |
| 454 | } |
| 455 | } else { |
| 456 | $get_image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); |
| 457 | $image = $get_image[0]; |
| 458 | $has_img = true; |
| 459 | } |
| 460 | |
| 461 | // Post author |
| 462 | if ( $facebook_url ) { |
| 463 | $author = $facebook_url; |
| 464 | } |
| 465 | |
| 466 | // Facebook publisher URL |
| 467 | if ( ! empty( $facebook_url ) ) { |
| 468 | $publisher = $facebook_url; |
| 469 | } |
| 470 | |
| 471 | // Facebook APP ID |
| 472 | $facebook_appid = get_theme_mod( 'ocean_facebook_appid' ); |
| 473 | if ( ! empty( $facebook_appid ) ) { |
| 474 | $fb_app_id = $facebook_appid; |
| 475 | } |
| 476 | |
| 477 | // Twiiter handle |
| 478 | $twitter_handle = '@' . str_replace( '@' , '' , get_theme_mod( 'ocean_twitter_handle' ) ); |
| 479 | |
| 480 | // Output |
| 481 | $output = self::opengraph_tag( 'property', 'og:type', trim( $type ) ); |
| 482 | $output .= self::opengraph_tag( 'property', 'og:title', trim( $title ) ); |
| 483 | |
| 484 | if ( isset( $description ) && ! empty( $description ) ) { |
| 485 | $output .= self::opengraph_tag( 'property', 'og:description', trim( $description ) ); |
| 486 | } |
| 487 | |
| 488 | if ( has_post_thumbnail( oceanwp_post_id() ) && true == $has_img ) { |
| 489 | $output .= self::opengraph_tag( 'property', 'og:image', trim( $image ) ); |
| 490 | $output .= self::opengraph_tag( 'property', 'og:image:width', absint( $get_image[1] ) ); |
| 491 | $output .= self::opengraph_tag( 'property', 'og:image:height', absint( $get_image[2] ) ); |
| 492 | } |
| 493 | |
| 494 | $output .= self::opengraph_tag( 'property', 'og:url', trim( get_permalink() ) ); |
| 495 | $output .= self::opengraph_tag( 'property', 'og:site_name', trim( get_bloginfo( 'name' ) ) ); |
| 496 | |
| 497 | if ( is_singular() && ! is_front_page() ) { |
| 498 | |
| 499 | if ( isset( $author ) && ! empty( $author ) ) { |
| 500 | $output .= self::opengraph_tag( 'property', 'article:author', trim( $author ) ); |
| 501 | } |
| 502 | |
| 503 | if ( is_singular( 'post' ) ) { |
| 504 | $output .= self::opengraph_tag( 'property', 'article:published_time', trim( get_post_time( 'c' ) ) ); |
| 505 | $output .= self::opengraph_tag( 'property', 'article:modified_time', trim( get_post_modified_time( 'c' ) ) ); |
| 506 | $output .= self::opengraph_tag( 'property', 'og:updated_time', trim( get_post_modified_time( 'c' ) ) ); |
| 507 | } |
| 508 | |
| 509 | } |
| 510 | |
| 511 | if ( is_singular() ) { |
| 512 | |
| 513 | $tags = get_the_tags(); |
| 514 | if ( ! is_wp_error( $tags ) && ( is_array( $tags ) && $tags !== array() ) ) { |
| 515 | foreach ( $tags as $tag ) { |
| 516 | $output .= self::opengraph_tag( 'property', 'article:tag', trim( $tag->name ) ); |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | $terms = get_the_category(); |
| 521 | if ( ! is_wp_error( $terms ) && ( is_array( $terms ) && $terms !== array() ) ) { |
| 522 | // We can only show one section here, so we take the first one. |
| 523 | $output .= self::opengraph_tag( 'property', 'article:section', trim( $terms[0]->name ) ); |
| 524 | } |
| 525 | |
| 526 | } |
| 527 | |
| 528 | if ( isset( $publisher ) && ! empty( $publisher ) ) { |
| 529 | $output .= self::opengraph_tag( 'property', 'article:publisher', trim( $publisher ) ); |
| 530 | } |
| 531 | |
| 532 | if ( isset( $fb_app_id ) && ! empty( $fb_app_id ) ) { |
| 533 | $output .= self::opengraph_tag( 'property', 'fb:app_id', trim( $fb_app_id ) ); |
| 534 | } |
| 535 | |
| 536 | |
| 537 | $output .= self::opengraph_tag( 'name', 'twitter:card', 'summary_large_image' ); |
| 538 | $output .= self::opengraph_tag( 'name', 'twitter:title', trim( $title ) ); |
| 539 | |
| 540 | if ( isset( $description ) && ! empty( $description ) ) { |
| 541 | $output .= self::opengraph_tag( 'name', 'twitter:description', trim( $description ) ); |
| 542 | } |
| 543 | |
| 544 | if ( has_post_thumbnail( get_the_ID() ) && true == $has_img ) { |
| 545 | $output .= self::opengraph_tag( 'name', 'twitter:image', trim( $image ) ); |
| 546 | } |
| 547 | |
| 548 | if ( isset( $twitter_handle ) && ! empty( $twitter_handle ) ) { |
| 549 | $output .= self::opengraph_tag( 'name', 'twitter:site', trim( $twitter_handle ) ); |
| 550 | $output .= self::opengraph_tag( 'name', 'twitter:creator', trim( $twitter_handle ) ); |
| 551 | } |
| 552 | |
| 553 | echo $output; |
| 554 | |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Get meta tags |
| 559 | * |
| 560 | * @since 1.5.1 |
| 561 | */ |
| 562 | public static function opengraph_tag( $attr, $property, $content ) { |
| 563 | echo '<meta ', esc_attr( $attr ), '="', esc_attr( $property ), '" content="', esc_attr( $content ), '" />', "\n"; |
| 564 | } |
| 565 | |
| 566 | /** |
| 567 | * Enqueue scripts |
| 568 | * |
| 569 | * @since 1.0.0 |
| 570 | */ |
| 571 | public function scripts() { |
| 572 | |
| 573 | // Load main stylesheet |
| 574 | wp_enqueue_style( 'oe-widgets-style', plugins_url( '/assets/css/widgets.css', __FILE__ ) ); |
| 575 | |
| 576 | // If rtl |
| 577 | if ( is_RTL() ) { |
| 578 | wp_enqueue_style( 'oe-widgets-style-rtl', plugins_url( '/assets/css/rtl.css', __FILE__ ) ); |
| 579 | } |
| 580 | |
| 581 | } |
| 582 | |
| 583 | } // End Class |
| 584 | |
| 585 | #-------------------------------------------------------------------------------- |
| 586 | #region Freemius |
| 587 | #-------------------------------------------------------------------------------- |
| 588 | |
| 589 | function owp_include_client_migration() { |
| 590 | require_once dirname( __FILE__ ) . '/includes/client-migration/edd.php'; |
| 591 | |
| 592 | owp_fs()->add_filter( 'has_paid_plan_account', '__return_false' ); |
| 593 | owp_fs()->add_filter( 'is_submenu_visible', 'owp_fs_is_submenu_visible', 10, 2 ); |
| 594 | } |
| 595 | |
| 596 | add_action( 'owp_fs_loaded', 'owp_include_client_migration' ); |
| 597 | |
| 598 | function owp_fs_is_submenu_visible( $is_visible, $submenu_id ) { |
| 599 | if ( 'pricing' === $submenu_id ) { |
| 600 | $show_pricing_transient = false; //get_transient( 'oceanwp_show_pricing' ); |
| 601 | |
| 602 | if ( is_string( $show_pricing_transient ) ) { |
| 603 | $show_pricing = ( 'yes' === $show_pricing_transient ); |
| 604 | } else { |
| 605 | $show_pricing = true; |
| 606 | |
| 607 | foreach ( OceanWP_EDD_License_Key::$paid_addons as $class_name => $data ) { |
| 608 | if ( ! class_exists( $class_name ) ) { |
| 609 | continue; |
| 610 | } |
| 611 | |
| 612 | if ( ! function_exists( $data['fs_shortcode'] ) ) { |
| 613 | continue; |
| 614 | } |
| 615 | |
| 616 | /** |
| 617 | * Initiate the Freemius instance before migrating. |
| 618 | * |
| 619 | * @var Freemius $addon_fs |
| 620 | */ |
| 621 | $addon_fs = call_user_func( $data['fs_shortcode'] ); |
| 622 | |
| 623 | if ( $addon_fs->has_active_valid_license() ) { |
| 624 | $licenses = $addon_fs->_get_license(); |
| 625 | |
| 626 | if ( is_object( $licenses ) && |
| 627 | FS_Plugin_License::is_valid_id( $licenses->parent_license_id ) |
| 628 | ) { |
| 629 | $show_pricing = false; |
| 630 | break; |
| 631 | } |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | // set_transient( |
| 636 | // 'oceanwp_show_pricing', |
| 637 | // $show_pricing ? 'yes' : 'no', |
| 638 | // WP_FS__TIME_5_MIN_IN_SEC |
| 639 | // ); |
| 640 | } |
| 641 | |
| 642 | return $show_pricing; |
| 643 | } |
| 644 | |
| 645 | return $is_visible; |
| 646 | } |
| 647 | |
| 648 | //function owp_fs_after_client_migration( $license_accessor ) { |
| 649 | // if ('OceanWP_EDD_License_Key' !== get_class($license_accessor)) { |
| 650 | // return; |
| 651 | // } |
| 652 | // |
| 653 | // delete_transient( 'oceanwp_show_pricing' ); |
| 654 | //} |
| 655 | // |
| 656 | //add_action( 'fs_after_client_migration', 'owp_fs_after_client_migration' ); |
| 657 | |
| 658 | #endregion |