assets
5 years ago
bin
5 years ago
languages
5 years ago
lib
5 years ago
templates
5 years ago
.jshintrc
6 years ago
Gruntfile.js
5 years ago
init.php
5 years ago
package.json
5 years ago
yit-deactive-plugin.php
9 years ago
yit-functions.php
5 years ago
yit-plugin-registration-hook.php
8 years ago
yit-plugin.php
5 years ago
yit-woocommerce-compatibility.php
8 years ago
yit-plugin.php
239 lines
| 1 | <?php |
| 2 | /** |
| 3 | * This file belongs to the YIT Plugin Framework. |
| 4 | * |
| 5 | * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0) |
| 6 | * that is bundled with this package in the file LICENSE.txt. |
| 7 | * It is also available through the world-wide-web at this URL: |
| 8 | * http://www.gnu.org/licenses/gpl-3.0.txt |
| 9 | */ |
| 10 | |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; |
| 13 | } // Exit if accessed directly |
| 14 | |
| 15 | |
| 16 | ! defined( 'YIT_CORE_PLUGIN' ) && define( 'YIT_CORE_PLUGIN', true); |
| 17 | ! defined( 'YIT_CORE_PLUGIN_PATH' ) && define( 'YIT_CORE_PLUGIN_PATH', dirname(__FILE__) ); |
| 18 | ! defined( 'YIT_CORE_PLUGIN_URL' ) && define( 'YIT_CORE_PLUGIN_URL', untrailingslashit( plugins_url( '/', __FILE__ ) ) ); |
| 19 | ! defined( 'YIT_CORE_PLUGIN_TEMPLATE_PATH' ) && define( 'YIT_CORE_PLUGIN_TEMPLATE_PATH', YIT_CORE_PLUGIN_PATH . '/templates' ); |
| 20 | |
| 21 | include_once( 'yit-functions.php' ); |
| 22 | include_once( 'yit-woocommerce-compatibility.php' ); |
| 23 | include_once( 'yit-plugin-registration-hook.php' ); |
| 24 | include_once( 'lib/yit-metabox.php' ); |
| 25 | include_once( 'lib/yit-plugin-panel.php' ); |
| 26 | include_once( 'lib/yit-plugin-panel-wc.php' ); |
| 27 | include_once( 'lib/yit-ajax.php' ); |
| 28 | include_once( 'lib/yit-plugin-subpanel.php' ); |
| 29 | include_once( 'lib/yit-plugin-common.php' ); |
| 30 | include_once( 'lib/yit-plugin-gradients.php'); |
| 31 | include_once( 'lib/yit-plugin-licence.php'); |
| 32 | include_once( 'lib/yit-theme-licence.php'); |
| 33 | include_once( 'lib/yit-video.php'); |
| 34 | include_once( 'lib/yit-upgrade.php'); |
| 35 | include_once( 'lib/yit-pointers.php'); |
| 36 | include_once( 'lib/yit-icons.php'); |
| 37 | include_once( 'lib/yit-assets.php'); |
| 38 | include_once( 'lib/yit-debug.php'); |
| 39 | include_once( 'lib/yith-dashboard.php' ); |
| 40 | include_once( 'lib/privacy/yit-privacy.php' ); |
| 41 | include_once( 'lib/privacy/yit-privacy-plugin-abstract.php' ); |
| 42 | include_once( 'lib/promo/yith-promo.php' ); |
| 43 | include_once( 'lib/yith-system-status.php' ); |
| 44 | |
| 45 | /* === Gutenberg Support === */ |
| 46 | if( class_exists( 'WP_Block_Type_Registry' ) ){ |
| 47 | include_once( 'lib/yith-gutenberg.php' ); |
| 48 | } |
| 49 | |
| 50 | // load from theme folder... |
| 51 | load_textdomain( 'yith-plugin-fw', get_template_directory() . '/core/plugin-fw/yith-plugin-fw-' . apply_filters( 'plugin_locale', get_locale(), 'yith-plugin-fw' ) . '.mo' ) |
| 52 | |
| 53 | // ...or from plugin folder |
| 54 | || load_textdomain( 'yith-plugin-fw', dirname(__FILE__) . '/languages/yith-plugin-fw-' . apply_filters( 'plugin_locale', get_locale(), 'yith-plugin-fw' ) . '.mo' ); |
| 55 | |
| 56 | add_filter( 'plugin_row_meta', 'yit_plugin_fw_row_meta', 20, 4 ); |
| 57 | |
| 58 | if( ! function_exists( 'yit_plugin_fw_row_meta' ) ){ |
| 59 | /** |
| 60 | * Hack the plugin author name from YITHEMES to YITH |
| 61 | * |
| 62 | * @param $plugin_meta |
| 63 | * @param $plugin_file |
| 64 | * @param $plugin_data |
| 65 | * @param $status |
| 66 | * |
| 67 | * @since 3.0.17 |
| 68 | * @author Andrea Grillo <andrea.grillo@yithemes.com> |
| 69 | * |
| 70 | * @return null|string|string[] $plugin row meta array |
| 71 | */ |
| 72 | function yit_plugin_fw_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ){ |
| 73 | $base_uri = array( |
| 74 | 'live_demo' => 'https://plugins.yithemes.com/', |
| 75 | 'documentation' => 'https://docs.yithemes.com/', |
| 76 | 'premium_support' => 'https://yithemes.com/my-account/support/dashboard/', |
| 77 | 'free_support' => 'https://wordpress.org/support/plugin/', |
| 78 | 'premium_version' => 'https://yithemes.com/themes/plugins/' |
| 79 | ); |
| 80 | |
| 81 | $default = array( |
| 82 | 'live_demo' => array( |
| 83 | 'label' => _x( 'Live Demo', 'Plugin Row Meta', 'yith-plugin-fw' ), |
| 84 | 'icon' => 'dashicons dashicons-laptop', |
| 85 | ), |
| 86 | |
| 87 | 'documentation' => array( |
| 88 | 'label' => _x( 'Documentation', 'Plugin Row Meta', 'yith-plugin-fw' ), |
| 89 | 'icon' => 'dashicons dashicons-search', |
| 90 | ), |
| 91 | |
| 92 | 'support' => array( |
| 93 | 'label' => _x( 'Support', 'Plugin Row Meta', 'yith-plugin-fw' ), |
| 94 | 'icon' => 'dashicons dashicons-admin-users', |
| 95 | ), |
| 96 | |
| 97 | 'premium_version' => array( |
| 98 | 'label' => _x( 'Premium version', 'Plugin Row Meta', 'yith-plugin-fw' ), |
| 99 | 'icon' => 'dashicons dashicons-cart', |
| 100 | ) |
| 101 | ); |
| 102 | |
| 103 | $to_show = array( 'live_demo', 'documentation', 'support', 'premium_version' ); |
| 104 | $new_row_meta_args = apply_filters( 'yith_show_plugin_row_meta', array( |
| 105 | 'to_show' => $to_show, |
| 106 | 'slug' => '' |
| 107 | ), $plugin_meta, $plugin_file, $plugin_data, $status ); |
| 108 | $fields = isset( $new_row_meta_args['to_show'] ) ? $new_row_meta_args['to_show'] : array(); |
| 109 | $slug = isset( $new_row_meta_args['slug'] ) ? $new_row_meta_args['slug'] : ''; |
| 110 | $is_premium = isset( $new_row_meta_args['is_premium'] ) ? $new_row_meta_args['is_premium'] : ''; |
| 111 | |
| 112 | if( true == $is_premium ){ |
| 113 | $to_remove = array_search( 'premium_version', $fields ); |
| 114 | |
| 115 | if( $to_remove !== false ){ |
| 116 | unset( $fields[ $to_remove ] ); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | foreach( $fields as $field ){ |
| 121 | $row_meta = isset( $new_row_meta_args[ $field ] ) ? wp_parse_args( $new_row_meta_args[ $field ], $default[ $field ] ) : $default[ $field ]; |
| 122 | $url = $icon = $label = ''; |
| 123 | |
| 124 | // Check for Label |
| 125 | if( isset( $row_meta['label'] ) ){ |
| 126 | $label = $row_meta['label']; |
| 127 | } |
| 128 | |
| 129 | // Check for Icon |
| 130 | if( isset( $row_meta['icon'] ) ){ |
| 131 | $icon = $row_meta['icon']; |
| 132 | } |
| 133 | |
| 134 | // Check for URL |
| 135 | if( isset( $row_meta['url'] ) ){ |
| 136 | $url = $row_meta['url']; |
| 137 | } |
| 138 | |
| 139 | else{ |
| 140 | if( ! empty( $slug ) ){ |
| 141 | if( 'support' == $field ){ |
| 142 | $support_field = $is_premium === true ? 'premium_support': 'free_support'; |
| 143 | if( ! empty( $base_uri[ $support_field ] ) ){ |
| 144 | $url = $base_uri[ $support_field ]; |
| 145 | } |
| 146 | |
| 147 | if( 'free_support' == $support_field ){ |
| 148 | $url = $url . $slug; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | else{ |
| 153 | if( isset( $base_uri[ $field ] ) ) { |
| 154 | $url = apply_filters( "yith_plugin_row_meta_{$field}_url", $base_uri[ $field ] . $slug, $field, $slug, $base_uri ); |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | if( ! empty( $url ) && ! empty( $label ) ){ |
| 161 | $url = trailingslashit( $url ); |
| 162 | $plugin_meta[] = sprintf( '<a href="%s" target="_blank"><span class="%s"></span>%s</a>', $url, $icon, $label ); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | //Author Name Hack |
| 167 | $plugin_meta = preg_replace('/>YITHEMES</', '>YITH<', $plugin_meta); |
| 168 | |
| 169 | return $plugin_meta; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | if( ! function_exists( 'yith_add_action_links' ) ){ |
| 174 | /** |
| 175 | * Action Links |
| 176 | * |
| 177 | * add the action links to plugin admin page |
| 178 | * |
| 179 | * @param $links | links plugin array |
| 180 | * |
| 181 | * @return mixed Array |
| 182 | * @since 1.6.5 |
| 183 | * @author Andrea Grillo <andrea.grillo@yithemes.com> |
| 184 | * @return mixed |
| 185 | * @use plugin_action_links_{$plugin_file_name} |
| 186 | */ |
| 187 | function yith_add_action_links( $links, $panel_page = '', $is_premium = false, $plugin_slug = '' ) { |
| 188 | $links = is_array( $links ) ? $links : array(); |
| 189 | if( ! empty( $panel_page ) ){ |
| 190 | $links[] = sprintf( '<a href="%s">%s</a>', admin_url( "admin.php?page={$panel_page}" ), _x( 'Settings', 'Action links', 'yith-plugin-fw' ) ); |
| 191 | } |
| 192 | |
| 193 | if( $is_premium && class_exists( 'YIT_Plugin_Licence' ) ){ |
| 194 | $links[] = sprintf( '<a href="%s">%s</a>', YIT_Plugin_Licence()->get_license_activation_url( $plugin_slug ),__( 'License', 'yith-plugin-fw' ) ); |
| 195 | } |
| 196 | |
| 197 | return $links; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /* === WooCommerce Update Message === */ |
| 202 | |
| 203 | /*if( apply_filters( 'yit_fw_wc_update_message_hook', true ) |
| 204 | && |
| 205 | ( function_exists( 'WC' ) && ! version_compare( WC()->version, '2.7', '>=' ) ) |
| 206 | && ! isset( $_COOKIE['yith_wc_2_7_notice'] ) |
| 207 | ){ |
| 208 | add_action( 'admin_notices', 'yit_fw_wc_update_message', 15 ); |
| 209 | add_action( 'admin_enqueue_scripts', 'yit_plugin_fw_dismissable_notice', 20 ); |
| 210 | |
| 211 | if( ! function_exists( 'yit_fw_wc_update_message' ) ){ |
| 212 | function yit_fw_wc_update_message(){ |
| 213 | ?> |
| 214 | <div id="yith-notice-is-dismissable" class="yith-wc-update-message notice notice-error is-dismissible"> |
| 215 | <?php $message = 'the new WooCommerce version 2.7 will be soon released. <strong>Before</strong> proceeding with the update, please verify the plugins you are using are already compatible. You can check the compatibility status of YITH products'; ?> |
| 216 | <?php $url = 'https://support.yithemes.com/hc/en-us/articles/215945378-Theme-and-Plugin-compatibility-with-WordPress-and-WooCommerce'; ?> |
| 217 | <p><?php printf( '<strong>%s</strong> - %s <a href="%s" target="_blank">HERE</a>.', 'Please note', $message, $url ); ?></p> |
| 218 | </div> |
| 219 | <?php |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | if( ! function_exists( 'yit_plugin_fw_dismissable_notice' ) ){ |
| 224 | function yit_plugin_fw_dismissable_notice(){ |
| 225 | $assets_path = str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/'; |
| 226 | wp_enqueue_script( 'jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie.min.js', array( 'jquery' ), '1.4.1', true); |
| 227 | $js = "jQuery( document ).ready( function(){ |
| 228 | jQuery( '#yith-notice-is-dismissable' ).find('.notice-dismiss').on( 'click', function(){ |
| 229 | jQuery.cookie('yith_wc_2_7_notice', 'dismiss', { path: '/' }); |
| 230 | } ); |
| 231 | } ); "; |
| 232 | |
| 233 | wp_add_inline_script( 'jquery-cookie', $js ); |
| 234 | } |
| 235 | } |
| 236 | }*/ |
| 237 | |
| 238 | /* ========================== */ |
| 239 |