PluginProbe ʕ •ᴥ•ʔ
Ocean Extra / 2.5.4
Ocean Extra v2.5.4
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 months ago languages 2 months ago sass 2 years ago changelog.txt 2 months ago index.php 9 years ago ocean-extra.php 2 months ago phpcs.xml.dist 3 years ago readme.txt 2 months ago wpml-config.xml 4 years ago
ocean-extra.php
1018 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.4
7 * Author: OceanWP
8 * Author URI: https://oceanwp.org/
9 * Requires at least: 5.6
10 * Tested up to: 6.9
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-2025, 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/dashboard.php';
505 // require_once OE_PATH . '/includes/panel/demos.php';
506 require_once OE_PATH . '/includes/plugins-tab.php';
507 $oe_notification_active_status = get_option( 'oe_notification_active_status', 'no' );
508 if( $oe_notification_active_status == 'no' ) {
509 require_once OE_PATH . '/includes/admin-bar/admin-bar.php';
510 require_once OE_PATH . '/includes/admin-bar/notifications.php';
511 }
512 require_once OE_PATH . '/includes/adobe-font.php';
513 require_once OE_PATH . '/includes/preloader/customizer.php';
514 require_once OE_PATH . '/includes/customizer/customizer.php';
515
516 add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ), 999 );
517 }
518 }
519
520 /**
521 * Include flickr widget class
522 *
523 * @since 1.0.0
524 */
525 public static function custom_widgets() {
526
527 if ( ! version_compare( PHP_VERSION, '5.6', '>=' ) ) {
528 return;
529 }
530
531 // Define array of custom widgets for the theme
532 $widgets = apply_filters(
533 'ocean_custom_widgets',
534 array(
535 'about-me',
536 'contact-info',
537 'custom-links',
538 'custom-menu',
539 'facebook',
540 'flickr',
541 'instagram',
542 'mailchimp',
543 'recent-posts',
544 'social',
545 'social-share',
546 'tags',
547 'twitter',
548 'video',
549 'custom-header-logo',
550 'custom-header-nav',
551 )
552 );
553
554 // Loop through widgets and load their files
555 if ( $widgets && is_array( $widgets ) ) {
556 foreach ( $widgets as $widget ) {
557 $file = OE_PATH . '/includes/widgets/' . $widget . '.php';
558 if ( file_exists( $file ) ) {
559 require_once $file;
560 }
561 }
562 }
563
564 }
565
566 /**
567 * Add meta tags
568 *
569 * @since 1.5.1
570 */
571 public static function meta_tags() {
572
573 // Return if disabled or if Yoast SEO enabled as they have their own meta tags
574 if ( false == get_theme_mod( 'ocean_open_graph', false )
575 || defined( 'WPSEO_VERSION' )
576 || defined( 'RANK_MATH_FILE' ) ) {
577 return;
578 }
579
580 // Facebook URL
581 $facebook_url = get_theme_mod( 'ocean_facebook_page_url' );
582
583 // Disable Jetpack's Open Graph tags
584 add_filter( 'jetpack_enable_opengraph', '__return_false', 99 );
585 add_filter( 'jetpack_enable_open_graph', '__return_false', 99 );
586 add_filter( 'jetpack_disable_twitter_cards', '__return_true', 99 );
587
588 // Type
589 if ( is_front_page() || is_home() ) {
590 $type = 'website';
591 } elseif ( is_singular() ) {
592 $type = 'article';
593 } else {
594 // We use "object" for archives etc. as article doesn't apply there.
595 $type = 'object';
596 }
597
598 // Title
599 if ( is_singular() ) {
600 $title = get_the_title();
601 } else {
602 $title = oceanwp_has_page_title();
603 }
604
605 // Description
606 if ( is_category() || is_tag() || is_tax() ) {
607 $description = strip_shortcodes( wp_strip_all_tags( term_description() ) );
608 } else {
609 $description = html_entity_decode( htmlspecialchars_decode( oceanwp_excerpt( 40 ) ) );
610 }
611
612 // Image.
613 $image = '';
614 $has_img = false;
615 if ( OCEANWP_WOOCOMMERCE_ACTIVE
616 && is_product_category() ) {
617 global $wp_query;
618 $cat = $wp_query->get_queried_object();
619 $thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
620 $get_image = wp_get_attachment_url( $thumbnail_id );
621 if ( $get_image ) {
622 $image = $get_image;
623 $has_img = true;
624 }
625 } else {
626 $get_image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' );
627
628 if ( is_array( $get_image ) ) {
629 $image = $get_image[0];
630 $has_img = true;
631 }
632 }
633
634 // Post author.
635 if ( $facebook_url ) {
636 $author = $facebook_url;
637 }
638
639 // Facebook publisher URL
640 if ( ! empty( $facebook_url ) ) {
641 $publisher = $facebook_url;
642 }
643
644 // Facebook APP ID
645 $facebook_appid = get_theme_mod( 'ocean_facebook_appid' );
646 if ( ! empty( $facebook_appid ) ) {
647 $fb_app_id = $facebook_appid;
648 }
649
650 // Twiiter handle
651 $twitter_handle = '@' . str_replace( '@', '', get_theme_mod( 'ocean_twitter_handle' ) );
652
653 // Output
654 $output = self::opengraph_tag( 'property', 'og:type', trim( $type ) );
655 $output .= self::opengraph_tag( 'property', 'og:title', trim( $title ) );
656
657 if ( isset( $description ) && ! empty( $description ) ) {
658 $output .= self::opengraph_tag( 'property', 'og:description', trim( $description ) );
659 }
660
661 if ( has_post_thumbnail( self::oe_post_id() ) && true == $has_img ) {
662 $output .= self::opengraph_tag( 'property', 'og:image', trim( $image ) );
663 $output .= self::opengraph_tag( 'property', 'og:image:width', absint( $get_image[1] ) );
664 $output .= self::opengraph_tag( 'property', 'og:image:height', absint( $get_image[2] ) );
665 }
666
667 $output .= self::opengraph_tag( 'property', 'og:url', trim( ocean_get_opengraph_url() ) );
668 $output .= self::opengraph_tag( 'property', 'og:site_name', trim( get_bloginfo( 'name' ) ) );
669
670 if ( is_singular() && ! is_front_page() ) {
671
672 if ( isset( $author ) && ! empty( $author ) ) {
673 $output .= self::opengraph_tag( 'property', 'article:author', trim( $author ) );
674 }
675
676 if ( is_singular( 'post' ) ) {
677 $output .= self::opengraph_tag( 'property', 'article:published_time', trim( get_post_time( 'c' ) ) );
678 $output .= self::opengraph_tag( 'property', 'article:modified_time', trim( get_post_modified_time( 'c' ) ) );
679 $output .= self::opengraph_tag( 'property', 'og:updated_time', trim( get_post_modified_time( 'c' ) ) );
680 }
681 }
682
683 if ( is_singular() ) {
684
685 $tags = get_the_tags();
686 if ( ! is_wp_error( $tags ) && ( is_array( $tags ) && $tags !== array() ) ) {
687 foreach ( $tags as $tag ) {
688 $output .= self::opengraph_tag( 'property', 'article:tag', trim( $tag->name ) );
689 }
690 }
691
692 $terms = get_the_category();
693 if ( ! is_wp_error( $terms ) && ( is_array( $terms ) && $terms !== array() ) ) {
694 // We can only show one section here, so we take the first one.
695 $output .= self::opengraph_tag( 'property', 'article:section', trim( $terms[0]->name ) );
696 }
697 }
698
699 if ( isset( $publisher ) && ! empty( $publisher ) ) {
700 $output .= self::opengraph_tag( 'property', 'article:publisher', trim( $publisher ) );
701 }
702
703 if ( isset( $fb_app_id ) && ! empty( $fb_app_id ) ) {
704 $output .= self::opengraph_tag( 'property', 'fb:app_id', trim( $fb_app_id ) );
705 }
706
707 // Twitter
708 $output .= self::opengraph_tag( 'name', 'twitter:card', 'summary_large_image' );
709 $output .= self::opengraph_tag( 'name', 'twitter:title', trim( $title ) );
710
711 if ( isset( $description ) && ! empty( $description ) ) {
712 $output .= self::opengraph_tag( 'name', 'twitter:description', trim( $description ) );
713 }
714
715 if ( has_post_thumbnail( get_the_ID() ) && true == $has_img ) {
716 $output .= self::opengraph_tag( 'name', 'twitter:image', trim( $image ) );
717 }
718
719 if ( isset( $twitter_handle ) && ! empty( $twitter_handle ) ) {
720 $output .= self::opengraph_tag( 'name', 'twitter:site', trim( $twitter_handle ) );
721 $output .= self::opengraph_tag( 'name', 'twitter:creator', trim( $twitter_handle ) );
722 }
723
724 echo $output;
725
726 }
727
728 /**
729 * Get meta tags
730 *
731 * @since 1.5.1
732 */
733 public static function opengraph_tag( $attr, $property, $content ) {
734 echo '<meta ', esc_attr( $attr ), '="', esc_attr( $property ), '" content="', esc_attr( $content ), '" />', "\n";
735 }
736
737 /**
738 * Enqueue scripts
739 *
740 * @since 1.0.0
741 */
742 public function scripts() {
743
744 // Load main stylesheet
745
746 if ( get_theme_mod( 'ocean_load_widgets_stylesheet', 'enabled' ) === 'disabled' ) {
747 return;
748 }
749
750 wp_enqueue_style( 'oe-widgets-style', plugins_url( '/assets/css/widgets.css', __FILE__ ) );
751
752 // If rtl
753 if ( is_RTL() ) {
754 wp_enqueue_style( 'oe-widgets-style-rtl', plugins_url( '/assets/css/rtl.css', __FILE__ ) );
755 }
756
757 }
758
759 } // End Class.
760
761 /**
762 * Get correct url for opengraph url tag.
763 *
764 * @since 3.4.3
765 */
766 if ( ! function_exists( 'ocean_get_opengraph_url' ) ) {
767 function ocean_get_opengraph_url() {
768 $url = '';
769 if ( empty( $url ) ) {
770 if ( is_singular() ) {
771 $url = get_permalink();
772 } else if ( is_author() ) {
773 $url = get_author_posts_url( get_query_var( 'author' ), get_query_var( 'author_name' ) );
774 } else if ( is_tax() || is_tag() || is_category() ) {
775 $term = get_queried_object();
776 $url = get_term_link( $term, $term->taxonomy );
777 } else if ( is_search() ) {
778 $url = get_search_link();
779 } else if ( is_front_page() ) {
780 $url = home_url();
781 } else if ( is_home() && 'page' === get_option( 'show_on_front' ) ) {
782 $url = get_permalink( get_option( 'page_for_posts' ) );
783 } else if ( is_post_type_archive() ) {
784 $post_type = get_query_var( 'post_type' );
785 if ( is_array( $post_type ) ) {
786 $post_type = reset( $post_type );
787 }
788 $url = get_post_type_archive_link( $post_type );
789 } else if ( is_archive() ) {
790 if ( is_date() ) {
791 if ( is_day() ) {
792 $url = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
793 } elseif ( is_month() ) {
794 $url = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
795 } elseif ( is_year() ) {
796 $url = get_year_link( get_query_var( 'year' ) );
797 }
798 }
799 }
800 }
801
802 $url = apply_filters( 'ocean_seo_opengraph_tag_url', $url );
803
804 return esc_url( $url );
805 }
806 }
807
808 /**
809 * Check link rel and return correct aria label
810 *
811 * @since 1.6.4
812 */
813
814 if ( ! function_exists( 'ocean_link_rel' ) ) {
815
816 function ocean_link_rel( $ocean_srt, $nofollow, $target ) {
817
818 if ( $nofollow === 'yes' ) {
819 if ( $target === 'blank' ) {
820 $link_rel = 'rel="nofollow noopener noreferrer"';
821 $ocean_sr = $ocean_srt;
822 } else {
823 $link_rel = 'rel="nofollow"';
824 $ocean_sr = '';
825 }
826 } elseif ( $nofollow === 'no' || $nofollow === '' ) {
827 if ( $target === 'blank' ) {
828 $link_rel = 'rel="noopener noreferrer"';
829 $ocean_sr = $ocean_srt;
830 } else {
831 $link_rel = '';
832 $ocean_sr = '';
833 }
834 }
835
836 return array( $ocean_sr, $link_rel );
837 }
838 }
839
840 /**
841 * Returns current theme version
842 *
843 * @since 2.0.0
844 */
845 function theme_version() {
846
847 // Get theme data.
848 $theme = wp_get_theme();
849
850 // Return theme version.
851 return $theme->get( 'Version' );
852
853 }
854
855 function oe_get_theme_version() {
856
857 $theme = wp_get_theme();
858
859 $current_theme_version = '';
860
861 if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) {
862
863 if ( get_template_directory() == get_stylesheet_directory() ) {
864 $current_theme_version = $theme->get( 'Version' );
865 } else {
866 $parent = $theme->parent();
867 if ( ! empty( $parent) ) {
868 $current_theme_version = $parent->Version;
869 }
870 }
871 }
872
873 return $current_theme_version;
874 }
875
876 /**
877 * Display Notice when Ocean Extra is outdated.
878 *
879 * @since 2.0.0
880 *
881 * @return void
882 */
883
884 if ( ! function_exists( 'ocean_theme_is_outdated_admin_notice' ) ) {
885 function ocean_theme_is_outdated_admin_notice() {
886 $theme = wp_get_theme();
887 if ( current_user_can( 'install_plugins' ) ) {
888 if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) {
889 if ( ! defined( 'OCEANWP_THEME_VERSION' ) ) {
890 define( 'OCEANWP_THEME_VERSION', theme_version() );
891 }
892 if ( ! is_child_theme() ) {
893 $current_theme_version = OCEANWP_THEME_VERSION;
894 } else {
895 $current_theme_version = '3.3.0';
896 }
897 $required_theme_version = '3.3.0';
898
899 if ( ! empty( $current_theme_version ) && ! empty( $required_theme_version ) && version_compare( $current_theme_version, $required_theme_version , '<' ) ) :
900 ?>
901 <div class="notice notice-warning is-dismissible">
902 <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>
903 <a href="<?php echo esc_url( admin_url( 'update-core.php' ) ); ?>"><?php esc_html_e( 'Update and get the new Theme Panel', 'oceanwp' ); ?></a>
904 <br><br>
905 </div>
906 <?php
907 endif;
908 }
909 }
910 }
911 }
912 add_action( 'admin_notices', 'ocean_theme_is_outdated_admin_notice' );
913
914 // --------------------------------------------------------------------------------
915 // region Freemius
916 // --------------------------------------------------------------------------------
917
918 function owp_include_client_migration() {
919 require_once dirname( __FILE__ ) . '/includes/client-migration/edd.php';
920
921 owp_fs()->add_filter( 'has_paid_plan_account', '__return_false' );
922 owp_fs()->add_filter( 'is_submenu_visible', 'owp_fs_is_submenu_visible', 10, 2 );
923 }
924
925 add_action( 'owp_fs_loaded', 'owp_include_client_migration' );
926
927 function owp_fs_is_submenu_visible( $is_visible, $submenu_id ) {
928 if ( 'pricing' === $submenu_id ) {
929 $show_pricing_transient = false; // get_transient( 'oceanwp_show_pricing' );
930
931 if ( is_string( $show_pricing_transient ) ) {
932 $show_pricing = ( 'yes' === $show_pricing_transient );
933 } else {
934 $show_pricing = true;
935
936 foreach ( OceanWP_EDD_License_Key::$paid_addons as $class_name => $data ) {
937 if ( ! class_exists( $class_name ) ) {
938 continue;
939 }
940
941 if ( ! function_exists( $data['fs_shortcode'] ) ) {
942 continue;
943 }
944
945 /**
946 * Initiate the Freemius instance before migrating.
947 *
948 * @var Freemius $addon_fs
949 */
950 $addon_fs = call_user_func( $data['fs_shortcode'] );
951
952 if ( $addon_fs->has_active_valid_license() ) {
953 $licenses = $addon_fs->_get_license();
954
955 if ( is_object( $licenses ) &&
956 FS_Plugin_License::is_valid_id( $licenses->parent_license_id )
957 ) {
958 $show_pricing = false;
959 break;
960 }
961 }
962 }
963
964 if( property_exists( 'OceanWP_EDD_License_Key', 'separate_addons' ) && !empty( OceanWP_EDD_License_Key::$separate_addons ) ) {
965 foreach ( OceanWP_EDD_License_Key::$separate_addons as $class_name => $data ) {
966 if ( ! class_exists( $class_name ) ) {
967 continue;
968 }
969
970 if ( ! function_exists( $data['fs_shortcode'] ) ) {
971 continue;
972 }
973
974 /**
975 * Initiate the Freemius instance before migrating.
976 *
977 * @var Freemius $addon_fs
978 */
979 $addon_fs = call_user_func( $data['fs_shortcode'] );
980
981 if ( $addon_fs->has_active_valid_license() ) {
982 $licenses = $addon_fs->_get_license();
983
984 if ( is_object( $licenses ) &&
985 FS_Plugin_License::is_valid_id( $licenses->id )
986 ) {
987 $show_pricing = false;
988 break;
989 }
990 }
991 }
992 }
993
994 // set_transient(
995 // 'oceanwp_show_pricing',
996 // $show_pricing ? 'yes' : 'no',
997 // WP_FS__TIME_5_MIN_IN_SEC
998 // );
999 }
1000
1001 return $show_pricing;
1002 }
1003
1004 return $is_visible;
1005 }
1006
1007 // function owp_fs_after_client_migration( $license_accessor ) {
1008 // if ('OceanWP_EDD_License_Key' !== get_class($license_accessor)) {
1009 // return;
1010 // }
1011 //
1012 // delete_transient( 'oceanwp_show_pricing' );
1013 // }
1014 //
1015 // add_action( 'fs_after_client_migration', 'owp_fs_after_client_migration' );
1016
1017 // endregion
1018