set_basename( file_exists( dirname( __FILE__ ) . '/includes/elementor/widgets/class-plugetune-slider-widget__premium_only.php' ), __FILE__ ); return; } if ( !function_exists( 'plugetune_fs' ) ) { function plugetune_fs() { global $plugetune_fs; if ( !isset( $plugetune_fs ) ) { require_once dirname( __FILE__ ) . '/vendor/freemius/start.php'; $plugetune_fs = fs_dynamic_init( array( 'id' => '42914', 'slug' => 'plugetune', 'premium_slug' => 'plugetune-pro', 'type' => 'plugin', 'public_key' => 'pk_d1b69a0d0578543b29be7bd9baa48', 'is_premium' => false, 'has_addons' => false, 'has_paid_plans' => true, 'is_org_compliant' => true, 'trial' => array( 'days' => 7, 'is_require_payment' => false, ), 'menu' => array( 'support' => false, ), 'is_live' => true, ) ); } return $plugetune_fs; } plugetune_fs(); do_action( 'plugetune_fs_loaded' ); plugetune_fs()->add_filter( 'is_submenu_visible', 'plugetune_fs_hide_native_menu_items', 10, 2 ); plugetune_fs()->add_filter( 'show_deactivation_feedback_form', '__return_false' ); plugetune_fs()->add_action( 'after_uninstall', 'plugetune_uninstall_all_sites' ); } /** * * Always removes temporary data (scheduled events, transients, import locks). * Removes settings and imported videos only when the site owner ticked * "Delete all data on uninstall" under Settings > Advanced. * * Moved here from uninstall.php because Freemius needs its own uninstall hook to run. * * @return void */ if ( !function_exists( 'plugetune_uninstall_site' ) ) { /** * Clean up the PlugeTune data of the current site. * * @return void */ function plugetune_uninstall_site() { global $wpdb; // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching if ( function_exists( '_get_cron_array' ) && function_exists( 'wp_unschedule_hook' ) ) { $plugetune_hooks = array(); $plugetune_cron = _get_cron_array(); if ( is_array( $plugetune_cron ) ) { foreach ( $plugetune_cron as $plugetune_events ) { foreach ( array_keys( (array) $plugetune_events ) as $plugetune_hook ) { if ( 0 === strpos( $plugetune_hook, 'plugetune_' ) ) { $plugetune_hooks[$plugetune_hook] = true; } } } } foreach ( array_keys( $plugetune_hooks ) as $plugetune_hook ) { wp_unschedule_hook( $plugetune_hook ); } } $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like( '_transient_plugetune_' ) . '%', $wpdb->esc_like( '_transient_timeout_plugetune_' ) . '%', $wpdb->esc_like( '_site_transient_plugetune_' ) . '%', $wpdb->esc_like( 'plugetune_lock_' ) . '%', $wpdb->esc_like( 'plugetune_pl_owner_' ) . '%' ) ); if ( '1' !== (string) get_option( 'plugetune_delete_data_on_uninstall', '0' ) ) { wp_cache_delete( 'alloptions', 'options' ); return; } do { $plugetune_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s LIMIT 100", 'plugetune_video' ) ); $plugetune_removed = 0; foreach ( $plugetune_ids as $plugetune_id ) { if ( wp_delete_post( (int) $plugetune_id, true ) ) { ++$plugetune_removed; } } } while ( $plugetune_removed > 0 ); $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE %s OR meta_key LIKE %s", $wpdb->esc_like( '_plugetune_' ) . '%', $wpdb->esc_like( 'plugetune_' ) . '%' ) ); $plugetune_theme_mods = array( 'plugetune_single_layout_preset', 'plugetune_single_card_style', 'plugetune_single_elements_gap', 'plugetune_single_container_padding', 'plugetune_single_content_padding', 'plugetune_single_font_family', 'plugetune_single_title_font_size', 'plugetune_single_desc_font_size', 'plugetune_single_meta_font_size', 'plugetune_single_bg_color', 'plugetune_single_show_sidebar', 'plugetune_single_show_breadcrumbs' ); foreach ( $plugetune_theme_mods as $plugetune_mod ) { remove_theme_mod( $plugetune_mod ); } $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like( 'plugetune_' ) . '%' ) ); wp_cache_delete( 'alloptions', 'options' ); // phpcs:enable } } if ( !function_exists( 'plugetune_uninstall_all_sites' ) ) { /** * Run the cleanup on a single site or on every site of a multisite network. * * @return void */ function plugetune_uninstall_all_sites() { if ( is_multisite() ) { $plugetune_site_ids = get_sites( array( 'fields' => 'ids', 'number' => 0, ) ); foreach ( $plugetune_site_ids as $plugetune_site_id ) { switch_to_blog( (int) $plugetune_site_id ); plugetune_uninstall_site(); restore_current_blog(); } } else { plugetune_uninstall_site(); } } } /** * Hide the SDK's own Account / Contact Us / Pricing menu entries while the admin menu is being built. * The pages themselves stay available and are rendered embedded by the plugin's own menu items. * * @param bool $is_visible Current visibility. * @param string $menu_id SDK menu item id. * @return bool */ if ( !function_exists( 'plugetune_fs_hide_native_menu_items' ) ) { function plugetune_fs_hide_native_menu_items( $is_visible, $menu_id ) { if ( doing_action( 'admin_menu' ) && in_array( $menu_id, array('account', 'contact', 'pricing'), true ) ) { return false; } return $is_visible; } } /** * Whether this site may use Pro features. * * Single source of truth for every Pro gate. It asks the Freemius integration. * * @return bool */ if ( !function_exists( 'plugetune_is_pro' ) ) { function plugetune_is_pro() { $fs = ( function_exists( 'plugetune_fs' ) ? plugetune_fs() : null ); if ( is_object( $fs ) && method_exists( $fs, 'can_use_premium_code' ) ) { if ( method_exists( $fs, 'is_premium' ) && !$fs->is_premium() ) { return false; } return (bool) $fs->can_use_premium_code(); } return false; } } /** * Whether this is the Pro (premium) build of the plugin, as opposed to the Free build. * * @return bool */ if ( !function_exists( 'plugetune_is_premium_build' ) ) { function plugetune_is_premium_build() { $fs = ( function_exists( 'plugetune_fs' ) ? plugetune_fs() : null ); return is_object( $fs ) && method_exists( $fs, 'is_premium' ) && $fs->is_premium(); } } /** * Admin Upgrade page (embedded Freemius pricing in the Pro build). * * @return string */ if ( !function_exists( 'plugetune_upgrade_page_url' ) ) { function plugetune_upgrade_page_url() { return admin_url( 'edit.php?post_type=plugetune_video&page=plugetune-upgrade' ); } } /** * "Browse is a Pro feature" message with a link to the Upgrade page. * * @return string HTML. */ if ( !function_exists( 'plugetune_browse_pro_message_html' ) ) { function plugetune_browse_pro_message_html() { $link = '' . esc_html__( 'upgrade to Pro', 'plugetune' ) . ''; return sprintf( /* translators: %s: "upgrade to Pro" link. */ esc_html__( 'Browse is a Pro feature. You can still paste a YouTube link manually, or %s to browse your channel.', 'plugetune' ), $link ); } } /** * Stop an AJAX request that needs Pro. * * @param string $message Message shown to the user. * @return void */ if ( !function_exists( 'plugetune_send_pro_required_error' ) ) { function plugetune_send_pro_required_error( $message = '' ) { if ( '' === $message ) { $message = __( 'This feature is available in PlugeTune Pro.', 'plugetune' ); } wp_send_json_error( array( 'code' => 'pro_required', 'message' => $message, 'upgrade_url' => plugetune_upgrade_page_url(), ) ); } } /** * Free sites only get the default play behaviour; popup and inline (click-to-play) are Pro. * * @param string $behavior Requested behaviour. * @return string */ if ( !function_exists( 'plugetune_limit_play_behavior' ) ) { function plugetune_limit_play_behavior( $behavior ) { if ( in_array( $behavior, array('popup', 'inline'), true ) && !plugetune_is_pro() ) { return 'single'; } return $behavior; } } // The rest of the plugin lives in a separate file. Its functions must not be declared in this file, // otherwise PHP declares them before the early return above and activating the Pro version // while the free version is active ends in a fatal "Cannot redeclare" error. if ( !defined( 'PLUGETUNE_FILE' ) ) { define( 'PLUGETUNE_FILE', __FILE__ ); } require_once dirname( __FILE__ ) . '/includes/plugetune-core.php';