PluginProbe ʕ •ᴥ•ʔ
Ocean Extra / 2.5.6
Ocean Extra v2.5.6
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.4.1 1.1.4.2 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.0.1 1.2.1 1.2.1.1 1.2.1.2 1.2.10 1.2.2 1.2.2.1 1.2.2.2 1.2.2.3 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.16 1.4.17 1.4.18 1.4.19 1.4.2 1.4.20 1.4.21 1.4.22 1.4.23 1.4.24 1.4.25 1.4.26 1.4.27 1.4.28 1.4.29 1.4.3 1.4.30 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.12 1.5.13 1.5.14 1.5.15 1.5.16 1.5.17 1.5.18 1.5.19 1.5.2 1.5.20 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6
ocean-extra / ocean-extra.php
ocean-extra Last commit date
assets 1 year ago includes 2 weeks ago languages 2 weeks ago sass 2 years ago changelog.txt 2 weeks ago index.php 9 years ago ocean-extra.php 2 weeks ago phpcs.xml.dist 3 years ago readme.txt 2 weeks ago wpml-config.xml 4 years ago
ocean-extra.php
1019 lines
1 <?php
2 /**
3 * Plugin Name: Ocean Extra
4 * Plugin URI: https://oceanwp.org/extension/ocean-extra/
5 * Description: Add extra features and flexibility to your OceanWP theme for a turbocharged premium experience and full control over every aspect of your website.
6 * Version: 2.5.6
7 * Author: OceanWP
8 * Author URI: https://oceanwp.org/
9 * Requires at least: 5.6
10 * Tested up to: 7.0
11 * OceanWP requires at least: 4.0.9
12 * Text Domain: ocean-extra
13 * Domain Path: /languages
14 *
15 * @package Ocean_Extra
16 * @copyright Copyright (C) 2016-2026, Ocean Extra by OceanWP LLC - https://oceanwp.org
17 * @category Core
18 * @author OceanWP
19 */
20
21 // Exit if accessed directly.
22 if ( ! defined( 'ABSPATH' ) ) {
23 exit;
24 }
25
26 /**
27 * Returns the main instance of Ocean_Extra to prevent the need to use globals.
28 *
29 * @since 1.0.0
30 * @return object Ocean_Extra
31 */
32 function Ocean_Extra() {
33 return Ocean_Extra::instance();
34 } // End Ocean_Extra()
35
36 Ocean_Extra();
37
38 /**
39 * Main Ocean_Extra Class
40 *
41 * @class Ocean_Extra
42 * @version 1.0.0
43 * @since 1.0.0
44 * @package Ocean_Extra
45 */
46 final class Ocean_Extra {
47 /**
48 * Ocean_Extra The single instance of Ocean_Extra.
49 *
50 * @var object
51 * @access private
52 * @since 1.0.0
53 */
54 private static $_instance = null;
55
56 /**
57 * The token.
58 *
59 * @var string
60 * @access public
61 * @since 1.0.0
62 */
63 public $token;
64
65 /**
66 * The version number.
67 *
68 * @var string
69 * @access public
70 * @since 1.0.0
71 */
72 public $version;
73
74 /**
75 * The plugin url.
76 *
77 * @var string
78 * @access public
79 * @since 2.1.7
80 */
81 public $plugin_url;
82
83 /**
84 * The plugin path.
85 *
86 * @var string
87 * @access public
88 * @since 2.1.7
89 */
90 public $plugin_path;
91
92 /**
93 * The plugin data.
94 *
95 * @var array
96 * @access public
97 */
98 public $plugin_data;
99
100 // Admin - Start
101 /**
102 * The admin object.
103 *
104 * @var object
105 * @access public
106 * @since 1.0.0
107 */
108 public $admin;
109
110 /**
111 * Constructor function.
112 *
113 * @access public
114 * @since 1.0.0
115 * @return void
116 */
117 public function __construct( $widget_areas = array() ) {
118 $this->token = 'ocean-extra';
119 $this->plugin_url = plugin_dir_url( __FILE__ );
120 $this->plugin_path = plugin_dir_path( __FILE__ );
121 $this->plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ), false );
122 $this->version = $this->plugin_data['Version'];
123
124 define( 'OE_URL', $this->plugin_url );
125 define( 'OE_PATH', $this->plugin_path );
126 define( 'OE_VERSION', $this->version );
127 define( 'OE_FILE_PATH', __FILE__ );
128 define( 'OE_ADMIN_PANEL_HOOK_PREFIX', 'theme-panel_page_oceanwp-panel' );
129
130 // WooCommerce Wishlist partner ID
131 if ( class_exists( 'TInvWL_Wishlist' ) ) {
132 define( 'TINVWL_PARTNER', 'oceanwporg' );
133 define( 'TINVWL_CAMPAIGN', 'oceanwp_theme' );
134 }
135
136 register_activation_hook( __FILE__, array( $this, 'install' ) );
137
138 add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
139
140 // Setup all the things
141 add_action( 'init', array( $this, 'setup' ) );
142
143 // Log version when plugin loaded.
144 add_action( 'plugins_loaded',array( $this, 'oe_log_options' ) );
145
146 add_filter('register_post_type_args', array( $this, 'oe_custom_field_support_metabox' ), 10, 2 );
147
148 // Menu icons
149 $theme = wp_get_theme();
150 if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) {
151
152 if ( get_template_directory() == get_stylesheet_directory() ) {
153 $current_theme_version = theme_version();
154 } else {
155 $parent = wp_get_theme()->parent();
156 // get parent version.
157 if ( ! empty( $parent) ) {
158 $current_theme_version = $parent->Version;
159 }
160 }
161 $required_theme_version = '3.3.3';
162
163 include_once $this->plugin_path . '/includes/update-message.php';
164
165 if ( file_exists( OE_PATH . '/includes/panel/theme-panel.php' ) ) {
166 require_once OE_PATH . '/includes/panel/theme-panel.php';
167 }
168
169 $oe_library_active_status = get_option( 'oe_library_active_status', 'yes' );
170 if( $oe_library_active_status == 'yes' ) {
171 require_once OE_PATH . '/includes/panel/library.php';
172 }
173 require_once OE_PATH . '/includes/panel/library-shortcode.php';
174 require_once OE_PATH . '/includes/menu-icons/menu-icons.php';
175 require_once OE_PATH . '/includes/onboarding/start.php';
176
177 require_once OE_PATH . '/includes/themepanel/theme-panel.php';
178
179 if ( ! empty( $current_theme_version ) && ! empty( $required_theme_version ) && version_compare( $current_theme_version, $required_theme_version , '>' ) ) {
180 require_once OE_PATH . '/includes/compatibility/ocean.php';
181 }
182
183 require_once OE_PATH . '/includes/preloader/preloader.php';
184
185 // Outputs custom JS to the footer
186 add_action( 'wp_footer', array( $this, 'custom_js' ), 9999 );
187
188 // Register Custom JS file
189 add_action( 'init', array( $this, 'register_custom_js' ) );
190
191 // Move the Custom CSS section into the Custom CSS/JS section
192 add_action( 'customize_register', array( $this, 'customize_register' ), 11 );
193
194 // Remove customizer unnecessary sections
195 add_action( 'customize_register', array( $this, 'remove_customize_sections' ), 11 );
196
197 // Load custom widgets
198 add_action( 'widgets_init', array( $this, 'custom_widgets' ), 10 );
199
200 // Add meta tags
201 add_filter( 'wp_head', array( $this, 'meta_tags' ), 1 );
202 }
203
204 // Allow shortcodes in text widgets
205 add_filter( 'widget_text', 'do_shortcode' );
206
207 // Allow for the use of shortcodes in the WordPress excerpt
208 add_filter( 'the_excerpt', 'shortcode_unautop' );
209 add_filter( 'the_excerpt', 'do_shortcode' );
210 }
211
212 /**
213 * Main Ocean_Extra Instance
214 *
215 * Ensures only one instance of Ocean_Extra is loaded or can be loaded.
216 *
217 * @since 1.0.0
218 * @static
219 * @see Ocean_Extra()
220 * @return Main Ocean_Extra instance
221 */
222 public static function instance() {
223 if ( is_null( self::$_instance ) ) {
224 self::$_instance = new self();
225 }
226 return self::$_instance;
227 } // End instance()
228
229 /**
230 * Load the localisation file.
231 *
232 * @access public
233 * @since 1.0.0
234 * @return void
235 */
236 public function load_plugin_textdomain() {
237 load_plugin_textdomain( 'ocean-extra', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
238 }
239
240 /**
241 * Cloning is forbidden.
242 *
243 * @since 1.0.0
244 */
245 public function __clone() {
246 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), '1.0.0' );
247 }
248
249 /**
250 * Deserializing instances of this class is forbidden.
251 *
252 * @since 1.0.0
253 */
254 public function __wakeup() {
255 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), '1.0.0' );
256 }
257
258 /**
259 * Installation.
260 * Runs on activation. Logs the version number and assigns a notice message to a WordPress option.
261 *
262 * @access public
263 * @since 1.0.0
264 * @return void
265 */
266 public function install() {
267 $this->_log_version_number();
268 $this->_log_installed_version_number();
269 }
270
271 /**
272 * Log Installed version.
273 *
274 * @access public
275 * @since 2.4.7
276 * @return void
277 */
278 public function oe_log_options() {
279 $this->_log_installed_version_number();
280 }
281
282 /**
283 * Log the plugin version number.
284 *
285 * @access private
286 * @since 1.0.0
287 * @return void
288 */
289 private function _log_version_number() {
290 // Log the version number.
291 update_option( $this->token . '-version', $this->version );
292 }
293
294 /**
295 * Log the plugin version number.
296 *
297 * @access private
298 * @since 2.4.7
299 * @return void
300 */
301 private function _log_installed_version_number() {
302
303 $option_name = $this->token . '-installed-version';
304
305 if (! get_option( $option_name ) ) {
306 update_option( $option_name, $this->version );
307 }
308 }
309
310 /**
311 * Return the correct icon
312 *
313 * @param string $icon Icon class.
314 * @param bool $echo Print string.
315 * @param string $class Icon class.
316 * @param string $title Optional SVG title.
317 * @param string $desc Optional SVG description.
318 * @param string $aria_hidden Optional SVG description.
319 * @param boolean $fallback Fallback icon.
320 *
321 * @since 1.7.6
322 * @return string OceanWP Icon.
323 */
324 public static function oe_svg_icon( $icon, $echo = true, $class = '', $title = '', $desc = '', $aria_hidden = true, $fallback = false ) {
325
326 // Get icon class.
327 $theme_icons = oceanwp_theme_icons();
328
329 if ( function_exists( 'oceanwp_icon' ) ) {
330 return oceanwp_icon( $icon, $echo, $class, $title, $desc, $aria_hidden, $fallback );
331 } else {
332
333 if ( true === $echo ) {
334 echo '<i class="' . $class . ' ' . $theme_icons[ $icon ]['fai'] . '"' . $aria_hidden . ' role="img"></i>';
335 } else {
336 return '<i class="' . $class . ' ' . $theme_icons[ $icon ]['fai'] . '"' . $aria_hidden . ' role="img"></i>';
337 }
338
339 return;
340
341 }
342 }
343
344 /**
345 * Return post id
346 *
347 * @since 2.2.8
348 * @return string Post id.
349 */
350 public static function oe_post_id() {
351
352 if ( function_exists( 'oceanwp_post_id' ) ) {
353 return oceanwp_post_id();
354 } else {
355 // Default value.
356 $id = '';
357
358 // If singular get_the_ID.
359 if ( is_singular() ) {
360 $id = get_the_ID();
361 }
362
363 // Get ID of WooCommerce product archive.
364 elseif ( OCEANWP_WOOCOMMERCE_ACTIVE && is_shop() ) {
365 $shop_id = wc_get_page_id( 'shop' );
366 if ( isset( $shop_id ) ) {
367 $id = $shop_id;
368 }
369 }
370
371 // Posts page.
372 elseif ( is_home() && $page_for_posts = get_option( 'page_for_posts' ) ) {
373 $id = $page_for_posts;
374 }
375
376 // Apply filters.
377 $id = apply_filters( 'ocean_post_id', $id );
378
379 // Sanitize.
380 $id = $id ? $id : '';
381
382 // Return ID.
383 return $id;
384 }
385
386 }
387
388 /**
389 * LearnDash compatibility with OceanWP Metabox.
390 */
391 public function oe_custom_field_support_metabox( $args, $post_type ) {
392
393 if ( 'sfwd-quiz' === $post_type
394 || 'sfwd-courses' === $post_type
395 || 'sfwd-lessons' === $post_type
396 || 'sfwd-topic' === $post_type
397 || 'ld-exam' === $post_type ) {
398 $args['supports'][] = 'custom-fields';
399 }
400
401 return $args;
402 }
403
404 /**
405 * All theme functions hook into the oceanwp_footer_js filter for this function.
406 *
407 * @since 1.3.8
408 */
409 public static function custom_js( $output = null ) {
410
411 // Add filter for adding custom js via other functions
412 $output = apply_filters( 'ocean_footer_js', $output );
413
414 // Minify and output JS in the wp_footer
415 if ( ! empty( $output ) ) { ?>
416
417 <script type="text/javascript">
418
419 /* OceanWP JS */
420 <?php echo \OceanWP\Minifier::minify( $output ); ?>
421
422 </script>
423
424 <?php
425 }
426
427 }
428
429 /**
430 * Adds customizer options
431 *
432 * @since 1.3.8
433 */
434 public function register_custom_js() {
435
436 // Var
437 $dir = OE_PATH . '/includes/';
438
439 // File
440 if ( Ocean_Extra_Theme_Panel::get_setting( 'oe_custom_code_panel' ) ) {
441 require_once $dir . 'custom-code.php';
442 }
443
444 }
445
446 /**
447 * Move the Custom CSS section into the Custom CSS/JS section
448 *
449 * @since 1.3.8
450 */
451 public static function customize_register( $wp_customize ) {
452
453 // Move custom css setting
454 $wp_customize->get_control( 'custom_css' )->section = 'ocean_custom_code_panel';
455
456 }
457
458 /**
459 * Remove customizer unnecessary sections
460 *
461 * @since 1.0.0
462 */
463 public static function remove_customize_sections( $wp_customize ) {
464
465 // Remove core sections
466 $wp_customize->remove_section( 'colors' );
467 $wp_customize->remove_section( 'themes' );
468 $wp_customize->remove_section( 'background_image' );
469
470 // Remove core controls
471 $wp_customize->remove_control( 'header_textcolor' );
472 $wp_customize->remove_control( 'background_color' );
473 $wp_customize->remove_control( 'background_image' );
474 $wp_customize->remove_control( 'display_header_text' );
475
476 // Remove default settings
477 $wp_customize->remove_setting( 'background_color' );
478 $wp_customize->remove_setting( 'background_image' );
479
480 }
481
482 /**
483 * Setup all the things.
484 * Only executes if OceanWP or a child theme using OceanWP as a parent is active and the extension specific filter returns true.
485 *
486 * @return void
487 */
488 public function setup() {
489 $theme = wp_get_theme();
490
491 if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) {
492 require_once OE_PATH . '/includes/utils.php';
493 require_once OE_PATH . '/includes/metabox/butterbean/butterbean.php';
494 require_once OE_PATH . '/includes/metabox/metabox.php';
495 require_once OE_PATH . '/includes/post-settings/post-settings.php';
496 require_once OE_PATH . '/includes/post-settings/apply-settings.php';
497 require_once OE_PATH . '/includes/post-settings/apply-shortcode.php';
498 require_once OE_PATH . '/includes/shortcodes/shortcodes.php';
499 require_once OE_PATH . '/includes/image-resizer.php';
500 require_once OE_PATH . '/includes/jshrink.php';
501 require_once OE_PATH . '/includes/panel/notice.php';
502 require_once OE_PATH . '/includes/walker.php';
503 require_once OE_PATH . '/includes/ocean-extra-strings.php';
504 require_once OE_PATH . '/includes/mautic.php';
505 require_once OE_PATH . '/includes/dashboard.php';
506 // require_once OE_PATH . '/includes/panel/demos.php';
507 require_once OE_PATH . '/includes/plugins-tab.php';
508 $oe_notification_active_status = get_option( 'oe_notification_active_status', 'no' );
509 if( $oe_notification_active_status == 'no' ) {
510 require_once OE_PATH . '/includes/admin-bar/admin-bar.php';
511 require_once OE_PATH . '/includes/admin-bar/notifications.php';
512 }
513 require_once OE_PATH . '/includes/adobe-font.php';
514 require_once OE_PATH . '/includes/preloader/customizer.php';
515 require_once OE_PATH . '/includes/customizer/customizer.php';
516
517 add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ), 999 );
518 }
519 }
520
521 /**
522 * Include flickr widget class
523 *
524 * @since 1.0.0
525 */
526 public static function custom_widgets() {
527
528 if ( ! version_compare( PHP_VERSION, '5.6', '>=' ) ) {
529 return;
530 }
531
532 // Define array of custom widgets for the theme
533 $widgets = apply_filters(
534 'ocean_custom_widgets',
535 array(
536 'about-me',
537 'contact-info',
538 'custom-links',
539 'custom-menu',
540 'facebook',
541 'flickr',
542 'instagram',
543 'mailchimp',
544 'recent-posts',
545 'social',
546 'social-share',
547 'tags',
548 'twitter',
549 'video',
550 'custom-header-logo',
551 'custom-header-nav',
552 )
553 );
554
555 // Loop through widgets and load their files
556 if ( $widgets && is_array( $widgets ) ) {
557 foreach ( $widgets as $widget ) {
558 $file = OE_PATH . '/includes/widgets/' . $widget . '.php';
559 if ( file_exists( $file ) ) {
560 require_once $file;
561 }
562 }
563 }
564
565 }
566
567 /**
568 * Add meta tags
569 *
570 * @since 1.5.1
571 */
572 public static function meta_tags() {
573
574 // Return if disabled or if Yoast SEO enabled as they have their own meta tags
575 if ( false == get_theme_mod( 'ocean_open_graph', false )
576 || defined( 'WPSEO_VERSION' )
577 || defined( 'RANK_MATH_FILE' ) ) {
578 return;
579 }
580
581 // Facebook URL
582 $facebook_url = get_theme_mod( 'ocean_facebook_page_url' );
583
584 // Disable Jetpack's Open Graph tags
585 add_filter( 'jetpack_enable_opengraph', '__return_false', 99 );
586 add_filter( 'jetpack_enable_open_graph', '__return_false', 99 );
587 add_filter( 'jetpack_disable_twitter_cards', '__return_true', 99 );
588
589 // Type
590 if ( is_front_page() || is_home() ) {
591 $type = 'website';
592 } elseif ( is_singular() ) {
593 $type = 'article';
594 } else {
595 // We use "object" for archives etc. as article doesn't apply there.
596 $type = 'object';
597 }
598
599 // Title
600 if ( is_singular() ) {
601 $title = get_the_title();
602 } else {
603 $title = oceanwp_has_page_title();
604 }
605
606 // Description
607 if ( is_category() || is_tag() || is_tax() ) {
608 $description = strip_shortcodes( wp_strip_all_tags( term_description() ) );
609 } else {
610 $description = html_entity_decode( htmlspecialchars_decode( oceanwp_excerpt( 40 ) ) );
611 }
612
613 // Image.
614 $image = '';
615 $has_img = false;
616 if ( OCEANWP_WOOCOMMERCE_ACTIVE
617 && is_product_category() ) {
618 global $wp_query;
619 $cat = $wp_query->get_queried_object();
620 $thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
621 $get_image = wp_get_attachment_url( $thumbnail_id );
622 if ( $get_image ) {
623 $image = $get_image;
624 $has_img = true;
625 }
626 } else {
627 $get_image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' );
628
629 if ( is_array( $get_image ) ) {
630 $image = $get_image[0];
631 $has_img = true;
632 }
633 }
634
635 // Post author.
636 if ( $facebook_url ) {
637 $author = $facebook_url;
638 }
639
640 // Facebook publisher URL
641 if ( ! empty( $facebook_url ) ) {
642 $publisher = $facebook_url;
643 }
644
645 // Facebook APP ID
646 $facebook_appid = get_theme_mod( 'ocean_facebook_appid' );
647 if ( ! empty( $facebook_appid ) ) {
648 $fb_app_id = $facebook_appid;
649 }
650
651 // Twiiter handle
652 $twitter_handle = '@' . str_replace( '@', '', get_theme_mod( 'ocean_twitter_handle' ) );
653
654 // Output
655 $output = self::opengraph_tag( 'property', 'og:type', trim( $type ) );
656 $output .= self::opengraph_tag( 'property', 'og:title', trim( $title ) );
657
658 if ( isset( $description ) && ! empty( $description ) ) {
659 $output .= self::opengraph_tag( 'property', 'og:description', trim( $description ) );
660 }
661
662 if ( has_post_thumbnail( self::oe_post_id() ) && true == $has_img ) {
663 $output .= self::opengraph_tag( 'property', 'og:image', trim( $image ) );
664 $output .= self::opengraph_tag( 'property', 'og:image:width', absint( $get_image[1] ) );
665 $output .= self::opengraph_tag( 'property', 'og:image:height', absint( $get_image[2] ) );
666 }
667
668 $output .= self::opengraph_tag( 'property', 'og:url', trim( ocean_get_opengraph_url() ) );
669 $output .= self::opengraph_tag( 'property', 'og:site_name', trim( get_bloginfo( 'name' ) ) );
670
671 if ( is_singular() && ! is_front_page() ) {
672
673 if ( isset( $author ) && ! empty( $author ) ) {
674 $output .= self::opengraph_tag( 'property', 'article:author', trim( $author ) );
675 }
676
677 if ( is_singular( 'post' ) ) {
678 $output .= self::opengraph_tag( 'property', 'article:published_time', trim( get_post_time( 'c' ) ) );
679 $output .= self::opengraph_tag( 'property', 'article:modified_time', trim( get_post_modified_time( 'c' ) ) );
680 $output .= self::opengraph_tag( 'property', 'og:updated_time', trim( get_post_modified_time( 'c' ) ) );
681 }
682 }
683
684 if ( is_singular() ) {
685
686 $tags = get_the_tags();
687 if ( ! is_wp_error( $tags ) && ( is_array( $tags ) && $tags !== array() ) ) {
688 foreach ( $tags as $tag ) {
689 $output .= self::opengraph_tag( 'property', 'article:tag', trim( $tag->name ) );
690 }
691 }
692
693 $terms = get_the_category();
694 if ( ! is_wp_error( $terms ) && ( is_array( $terms ) && $terms !== array() ) ) {
695 // We can only show one section here, so we take the first one.
696 $output .= self::opengraph_tag( 'property', 'article:section', trim( $terms[0]->name ) );
697 }
698 }
699
700 if ( isset( $publisher ) && ! empty( $publisher ) ) {
701 $output .= self::opengraph_tag( 'property', 'article:publisher', trim( $publisher ) );
702 }
703
704 if ( isset( $fb_app_id ) && ! empty( $fb_app_id ) ) {
705 $output .= self::opengraph_tag( 'property', 'fb:app_id', trim( $fb_app_id ) );
706 }
707
708 // Twitter
709 $output .= self::opengraph_tag( 'name', 'twitter:card', 'summary_large_image' );
710 $output .= self::opengraph_tag( 'name', 'twitter:title', trim( $title ) );
711
712 if ( isset( $description ) && ! empty( $description ) ) {
713 $output .= self::opengraph_tag( 'name', 'twitter:description', trim( $description ) );
714 }
715
716 if ( has_post_thumbnail( get_the_ID() ) && true == $has_img ) {
717 $output .= self::opengraph_tag( 'name', 'twitter:image', trim( $image ) );
718 }
719
720 if ( isset( $twitter_handle ) && ! empty( $twitter_handle ) ) {
721 $output .= self::opengraph_tag( 'name', 'twitter:site', trim( $twitter_handle ) );
722 $output .= self::opengraph_tag( 'name', 'twitter:creator', trim( $twitter_handle ) );
723 }
724
725 echo $output;
726
727 }
728
729 /**
730 * Get meta tags
731 *
732 * @since 1.5.1
733 */
734 public static function opengraph_tag( $attr, $property, $content ) {
735 echo '<meta ', esc_attr( $attr ), '="', esc_attr( $property ), '" content="', esc_attr( $content ), '" />', "\n";
736 }
737
738 /**
739 * Enqueue scripts
740 *
741 * @since 1.0.0
742 */
743 public function scripts() {
744
745 // Load main stylesheet
746
747 if ( get_theme_mod( 'ocean_load_widgets_stylesheet', 'enabled' ) === 'disabled' ) {
748 return;
749 }
750
751 wp_enqueue_style( 'oe-widgets-style', plugins_url( '/assets/css/widgets.css', __FILE__ ) );
752
753 // If rtl
754 if ( is_RTL() ) {
755 wp_enqueue_style( 'oe-widgets-style-rtl', plugins_url( '/assets/css/rtl.css', __FILE__ ) );
756 }
757
758 }
759
760 } // End Class.
761
762 /**
763 * Get correct url for opengraph url tag.
764 *
765 * @since 3.4.3
766 */
767 if ( ! function_exists( 'ocean_get_opengraph_url' ) ) {
768 function ocean_get_opengraph_url() {
769 $url = '';
770 if ( empty( $url ) ) {
771 if ( is_singular() ) {
772 $url = get_permalink();
773 } else if ( is_author() ) {
774 $url = get_author_posts_url( get_query_var( 'author' ), get_query_var( 'author_name' ) );
775 } else if ( is_tax() || is_tag() || is_category() ) {
776 $term = get_queried_object();
777 $url = get_term_link( $term, $term->taxonomy );
778 } else if ( is_search() ) {
779 $url = get_search_link();
780 } else if ( is_front_page() ) {
781 $url = home_url();
782 } else if ( is_home() && 'page' === get_option( 'show_on_front' ) ) {
783 $url = get_permalink( get_option( 'page_for_posts' ) );
784 } else if ( is_post_type_archive() ) {
785 $post_type = get_query_var( 'post_type' );
786 if ( is_array( $post_type ) ) {
787 $post_type = reset( $post_type );
788 }
789 $url = get_post_type_archive_link( $post_type );
790 } else if ( is_archive() ) {
791 if ( is_date() ) {
792 if ( is_day() ) {
793 $url = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
794 } elseif ( is_month() ) {
795 $url = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
796 } elseif ( is_year() ) {
797 $url = get_year_link( get_query_var( 'year' ) );
798 }
799 }
800 }
801 }
802
803 $url = apply_filters( 'ocean_seo_opengraph_tag_url', $url );
804
805 return esc_url( $url );
806 }
807 }
808
809 /**
810 * Check link rel and return correct aria label
811 *
812 * @since 1.6.4
813 */
814
815 if ( ! function_exists( 'ocean_link_rel' ) ) {
816
817 function ocean_link_rel( $ocean_srt, $nofollow, $target ) {
818
819 if ( $nofollow === 'yes' ) {
820 if ( $target === 'blank' ) {
821 $link_rel = 'rel="nofollow noopener noreferrer"';
822 $ocean_sr = $ocean_srt;
823 } else {
824 $link_rel = 'rel="nofollow"';
825 $ocean_sr = '';
826 }
827 } elseif ( $nofollow === 'no' || $nofollow === '' ) {
828 if ( $target === 'blank' ) {
829 $link_rel = 'rel="noopener noreferrer"';
830 $ocean_sr = $ocean_srt;
831 } else {
832 $link_rel = '';
833 $ocean_sr = '';
834 }
835 }
836
837 return array( $ocean_sr, $link_rel );
838 }
839 }
840
841 /**
842 * Returns current theme version
843 *
844 * @since 2.0.0
845 */
846 function theme_version() {
847
848 // Get theme data.
849 $theme = wp_get_theme();
850
851 // Return theme version.
852 return $theme->get( 'Version' );
853
854 }
855
856 function oe_get_theme_version() {
857
858 $theme = wp_get_theme();
859
860 $current_theme_version = '';
861
862 if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) {
863
864 if ( get_template_directory() == get_stylesheet_directory() ) {
865 $current_theme_version = $theme->get( 'Version' );
866 } else {
867 $parent = $theme->parent();
868 if ( ! empty( $parent) ) {
869 $current_theme_version = $parent->Version;
870 }
871 }
872 }
873
874 return $current_theme_version;
875 }
876
877 /**
878 * Display Notice when Ocean Extra is outdated.
879 *
880 * @since 2.0.0
881 *
882 * @return void
883 */
884
885 if ( ! function_exists( 'ocean_theme_is_outdated_admin_notice' ) ) {
886 function ocean_theme_is_outdated_admin_notice() {
887 $theme = wp_get_theme();
888 if ( current_user_can( 'install_plugins' ) ) {
889 if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) {
890 if ( ! defined( 'OCEANWP_THEME_VERSION' ) ) {
891 define( 'OCEANWP_THEME_VERSION', theme_version() );
892 }
893 if ( ! is_child_theme() ) {
894 $current_theme_version = OCEANWP_THEME_VERSION;
895 } else {
896 $current_theme_version = '3.3.0';
897 }
898 $required_theme_version = '3.3.0';
899
900 if ( ! empty( $current_theme_version ) && ! empty( $required_theme_version ) && version_compare( $current_theme_version, $required_theme_version , '<' ) ) :
901 ?>
902 <div class="notice notice-warning is-dismissible">
903 <p><?php esc_html_e( 'We made changes to our Theme Panel. To complete the installation and enjoy both old and new features, please make sure the OceanWP theme and all Ocean plugins are up to date.', 'oceanwp' ); ?></p>
904 <a href="<?php echo esc_url( admin_url( 'update-core.php' ) ); ?>"><?php esc_html_e( 'Update and get the new Theme Panel', 'oceanwp' ); ?></a>
905 <br><br>
906 </div>
907 <?php
908 endif;
909 }
910 }
911 }
912 }
913 add_action( 'admin_notices', 'ocean_theme_is_outdated_admin_notice' );
914
915 // --------------------------------------------------------------------------------
916 // region Freemius
917 // --------------------------------------------------------------------------------
918
919 function owp_include_client_migration() {
920 require_once dirname( __FILE__ ) . '/includes/client-migration/edd.php';
921
922 owp_fs()->add_filter( 'has_paid_plan_account', '__return_false' );
923 owp_fs()->add_filter( 'is_submenu_visible', 'owp_fs_is_submenu_visible', 10, 2 );
924 }
925
926 add_action( 'owp_fs_loaded', 'owp_include_client_migration' );
927
928 function owp_fs_is_submenu_visible( $is_visible, $submenu_id ) {
929 if ( 'pricing' === $submenu_id ) {
930 $show_pricing_transient = false; // get_transient( 'oceanwp_show_pricing' );
931
932 if ( is_string( $show_pricing_transient ) ) {
933 $show_pricing = ( 'yes' === $show_pricing_transient );
934 } else {
935 $show_pricing = true;
936
937 foreach ( OceanWP_EDD_License_Key::$paid_addons as $class_name => $data ) {
938 if ( ! class_exists( $class_name ) ) {
939 continue;
940 }
941
942 if ( ! function_exists( $data['fs_shortcode'] ) ) {
943 continue;
944 }
945
946 /**
947 * Initiate the Freemius instance before migrating.
948 *
949 * @var Freemius $addon_fs
950 */
951 $addon_fs = call_user_func( $data['fs_shortcode'] );
952
953 if ( $addon_fs->has_active_valid_license() ) {
954 $licenses = $addon_fs->_get_license();
955
956 if ( is_object( $licenses ) &&
957 FS_Plugin_License::is_valid_id( $licenses->parent_license_id )
958 ) {
959 $show_pricing = false;
960 break;
961 }
962 }
963 }
964
965 if( property_exists( 'OceanWP_EDD_License_Key', 'separate_addons' ) && !empty( OceanWP_EDD_License_Key::$separate_addons ) ) {
966 foreach ( OceanWP_EDD_License_Key::$separate_addons as $class_name => $data ) {
967 if ( ! class_exists( $class_name ) ) {
968 continue;
969 }
970
971 if ( ! function_exists( $data['fs_shortcode'] ) ) {
972 continue;
973 }
974
975 /**
976 * Initiate the Freemius instance before migrating.
977 *
978 * @var Freemius $addon_fs
979 */
980 $addon_fs = call_user_func( $data['fs_shortcode'] );
981
982 if ( $addon_fs->has_active_valid_license() ) {
983 $licenses = $addon_fs->_get_license();
984
985 if ( is_object( $licenses ) &&
986 FS_Plugin_License::is_valid_id( $licenses->id )
987 ) {
988 $show_pricing = false;
989 break;
990 }
991 }
992 }
993 }
994
995 // set_transient(
996 // 'oceanwp_show_pricing',
997 // $show_pricing ? 'yes' : 'no',
998 // WP_FS__TIME_5_MIN_IN_SEC
999 // );
1000 }
1001
1002 return $show_pricing;
1003 }
1004
1005 return $is_visible;
1006 }
1007
1008 // function owp_fs_after_client_migration( $license_accessor ) {
1009 // if ('OceanWP_EDD_License_Key' !== get_class($license_accessor)) {
1010 // return;
1011 // }
1012 //
1013 // delete_transient( 'oceanwp_show_pricing' );
1014 // }
1015 //
1016 // add_action( 'fs_after_client_migration', 'owp_fs_after_client_migration' );
1017
1018 // endregion
1019