| @@ -73,10 +73,8 @@ | ||
| 73 | 73 | $this->_addAction( 'visualizer_chart_schedules_spl', 'addSplChartSchedules', null, 10, 3 ); |
| 74 | 74 | |
| 75 | 75 | $this->_addAction( 'admin_init', 'init' ); |
| 76 | 76 | |
| 77 | - $this->_addAction( 'visualizer_chart_languages', 'addMultilingualSupport' ); | |
| 78 | - | |
| 79 | 77 | if ( defined( 'TI_CYPRESS_TESTING' ) ) { |
| 80 | 78 | $this->load_cypress_hooks(); |
| 81 | 79 | } |
| 82 | 80 | |
| @@ -670,9 +668,9 @@ | ||
| 670 | 668 | Visualizer_Plugin::NAME, |
| 671 | 669 | __( 'Chart Library', 'visualizer' ), |
| 672 | 670 | __( 'Chart Library', 'visualizer' ), |
| 673 | 671 | 'edit_posts', |
| 674 | - 'admin.php?page=' . Visualizer_Plugin::NAME | |
| 672 | + admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME ) | |
| 675 | 673 | ); |
| 676 | 674 | add_submenu_page( |
| 677 | 675 | Visualizer_Plugin::NAME, |
| 678 | 676 | __( 'Add New Chart', 'visualizer' ), |
| @@ -677,9 +675,9 @@ | ||
| 677 | 675 | Visualizer_Plugin::NAME, |
| 678 | 676 | __( 'Add New Chart', 'visualizer' ), |
| 679 | 677 | __( 'Add New Chart', 'visualizer' ), |
| 680 | 678 | 'edit_posts', |
| 681 | - 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew' | |
| 679 | + admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew' ) | |
| 682 | 680 | ); |
| 683 | 681 | add_submenu_page( |
| 684 | 682 | Visualizer_Plugin::NAME, |
| 685 | 683 | __( 'Support', 'visualizer' ), |
| @@ -688,12 +686,22 @@ | ||
| 688 | 686 | 'viz-support', |
| 689 | 687 | array( $this, 'renderSupportPage' ) |
| 690 | 688 | ); |
| 691 | 689 | |
| 690 | + if ( ! Visualizer_Module::is_pro() ) { | |
| 691 | + add_submenu_page( | |
| 692 | + Visualizer_Plugin::NAME, | |
| 693 | + __( 'Get Visualizer Pro', 'visualizer' ), | |
| 694 | + __( 'Get Visualizer Pro', 'visualizer' ), | |
| 695 | + 'edit_posts', | |
| 696 | + 'viz-get-pro', | |
| 697 | + '__return_null' | |
| 698 | + ); | |
| 699 | + add_action( 'admin_footer', array( $this, 'handleGetProSubMenu' ) ); | |
| 700 | + } | |
| 692 | 701 | remove_submenu_page( Visualizer_Plugin::NAME, Visualizer_Plugin::NAME ); |
| 693 | 702 | |
| 694 | 703 | add_action( "load-{$this->_libraryPage}", array( $this, 'addScreenOptions' ) ); |
| 695 | - add_action( 'admin_footer', array( $this, 'handleGetProSubMenu' ) ); | |
| 696 | 704 | } |
| 697 | 705 | |
| 698 | 706 | /** |
| 699 | 707 | * Handle get pro plugin submenu. |
| @@ -698,35 +706,32 @@ | ||
| 698 | 706 | /** |
| 699 | 707 | * Handle get pro plugin submenu. |
| 700 | 708 | */ |
| 701 | 709 | public function handleGetProSubMenu() { |
| 702 | - if ( ! Visualizer_Module::is_pro() ) { | |
| 703 | - ?> | |
| 710 | + ?> | |
| 704 | 711 | <style type="text/css"> |
| 705 | - #toplevel_page_visualizer ul.wp-submenu li:last-child { | |
| 712 | + #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li { | |
| 706 | 713 | background: #FF7E65; |
| 707 | 714 | font-size: 14px; |
| 708 | 715 | font-weight: 600; |
| 709 | 716 | color: #fff; |
| 710 | 717 | } |
| 711 | - #toplevel_page_visualizer ul.wp-submenu li:last-child > a { | |
| 718 | + #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li > a { | |
| 712 | 719 | color: #fff !important; |
| 713 | 720 | } |
| 714 | - #toplevel_page_visualizer ul.wp-submenu li:last-child > a:hover { | |
| 721 | + #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li > a:hover { | |
| 715 | 722 | box-shadow: inherit; |
| 716 | 723 | } |
| 717 | 724 | </style> |
| 718 | - <?php | |
| 719 | - if ( get_option( 'visualizer_fresh_install', false ) ) { | |
| 720 | - ?> | |
| 721 | - <style type="text/css"> | |
| 722 | - #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li { | |
| 723 | - display: none; | |
| 724 | - } | |
| 725 | - </style> | |
| 726 | - <?php | |
| 727 | - } | |
| 728 | - } | |
| 725 | + <script type="text/javascript"> | |
| 726 | + jQuery( document ).ready( function() { | |
| 727 | + jQuery( '#toplevel_page_visualizer' ).on( 'click', 'li:not(.wp-submenu-head, .wp-first-item):eq(2)', function( e ) { | |
| 728 | + e.preventDefault(); | |
| 729 | + window.open( 'https://themeisle.com/plugins/visualizer-charts-and-graphs/upgrade/#pricing', '_blank' ); | |
| 730 | + } ); | |
| 731 | + } ); | |
| 732 | + </script> | |
| 733 | + <?php | |
| 729 | 734 | } |
| 730 | 735 | |
| 731 | 736 | /** |
| 732 | 737 | * Adds the screen options for pagination. |
| @@ -760,24 +765,8 @@ | ||
| 760 | 765 | * Adds the display filters to be used in the meta_query while displaying the charts. |
| 761 | 766 | */ |
| 762 | 767 | private function getDisplayFilters( &$query_args ) { |
| 763 | 768 | $query = array(); |
| 764 | - global $sitepress; | |
| 765 | - if ( Visualizer_Module::is_pro() && ( function_exists( 'icl_get_languages' ) && $sitepress instanceof \SitePress ) ) { | |
| 766 | - $current_lang = icl_get_current_language(); | |
| 767 | - if ( in_array( $current_lang, array( 'all', icl_get_default_language() ), true ) ) { | |
| 768 | - $query[] = array( | |
| 769 | - 'key' => 'chart_lang', | |
| 770 | - 'compare' => 'NOT EXISTS', | |
| 771 | - ); | |
| 772 | - } else { | |
| 773 | - $query[] = array( | |
| 774 | - 'key' => 'chart_lang', | |
| 775 | - 'value' => $current_lang, | |
| 776 | - 'compare' => '=', | |
| 777 | - ); | |
| 778 | - } | |
| 779 | - } | |
| 780 | 769 | |
| 781 | 770 | // add chart type filter to the query arguments |
| 782 | 771 | $type = filter_input( INPUT_GET, 'type' ); |
| 783 | 772 | if ( $type && in_array( $type, Visualizer_Plugin::getChartTypes(), true ) ) { |
| @@ -875,9 +864,9 @@ | ||
| 875 | 864 | |
| 876 | 865 | $this->getDisplayFilters( $query_args ); |
| 877 | 866 | |
| 878 | 867 | // Added by Ash/Upwork |
| 879 | - $filterByMeta = ! empty( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 868 | + $filterByMeta = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING ); | |
| 880 | 869 | if ( $filterByMeta ) { |
| 881 | 870 | $query = array( |
| 882 | 871 | 'key' => Visualizer_Plugin::CF_SETTINGS, |
| 883 | 872 | 'value' => $filterByMeta, |
| @@ -899,9 +888,8 @@ | ||
| 899 | 888 | * @access public |
| 900 | 889 | */ |
| 901 | 890 | public function renderSupportPage() { |
| 902 | 891 | wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION ); |
| 903 | - $this->load_survey(); | |
| 904 | 892 | include_once VISUALIZER_ABSPATH . '/templates/support.php'; |
| 905 | 893 | } |
| 906 | 894 | |
| 907 | 895 | /** |
| @@ -979,15 +967,8 @@ | ||
| 979 | 967 | $css .= $arguments[0]; |
| 980 | 968 | $settings = $arguments[1]; |
| 981 | 969 | } |
| 982 | 970 | |
| 983 | - if ( isset( $settings['controls']['ui']['labelStacking'] ) ) { | |
| 984 | - unset( $settings['controls']['ui']['labelStacking'] ); | |
| 985 | - } | |
| 986 | - if ( isset( $settings['controls']['ui']['orientation'] ) ) { | |
| 987 | - unset( $settings['controls']['ui']['orientation'] ); | |
| 988 | - } | |
| 989 | - | |
| 990 | 971 | // add chart to the array |
| 991 | 972 | $charts[ $id ] = array( |
| 992 | 973 | 'id' => $chart->ID, |
| 993 | 974 | 'type' => $type, |
| @@ -1053,11 +1034,8 @@ | ||
| 1053 | 1034 | 'total' => $query->max_num_pages, |
| 1054 | 1035 | 'type' => 'array', |
| 1055 | 1036 | ) |
| 1056 | 1037 | ); |
| 1057 | - | |
| 1058 | - $this->load_survey(); | |
| 1059 | - | |
| 1060 | 1038 | $render->render(); |
| 1061 | 1039 | } |
| 1062 | 1040 | |
| 1063 | 1041 | /** |
| @@ -1107,9 +1085,9 @@ | ||
| 1107 | 1085 | esc_html__( 'Docs', 'visualizer' ) |
| 1108 | 1086 | ); |
| 1109 | 1087 | // flattr link |
| 1110 | 1088 | $plugin_meta[] = sprintf( |
| 1111 | - '<a style="color:red" href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'pluginrow' ) . '" target="_blank">%s</a>', | |
| 1089 | + '<a style="color:red" href="' . Visualizer_Plugin::PRO_TEASER_URL . '" target="_blank">%s</a>', | |
| 1112 | 1090 | esc_html__( 'Pro Addon', 'visualizer' ) |
| 1113 | 1091 | ); |
| 1114 | 1092 | } |
| 1115 | 1093 | |
| @@ -1125,136 +1103,6 @@ | ||
| 1125 | 1103 | if ( Visualizer_Module::is_pro() ) { |
| 1126 | 1104 | return true; |
| 1127 | 1105 | } |
| 1128 | 1106 | return 'yes' === get_option( 'visualizer-new-user', 'yes' ) ? false : true; |
| 1129 | - } | |
| 1130 | - | |
| 1131 | - /** | |
| 1132 | - * Multilingual Support. | |
| 1133 | - * | |
| 1134 | - * @param int $chart_id Chart ID. | |
| 1135 | - * @return bool Default false | |
| 1136 | - */ | |
| 1137 | - public function addMultilingualSupport( $chart_id ) { | |
| 1138 | - global $sitepress; | |
| 1139 | - if ( Visualizer_Module::is_pro() ) { | |
| 1140 | - return; | |
| 1141 | - } | |
| 1142 | - if ( function_exists( 'icl_get_languages' ) && $sitepress instanceof \SitePress ) { | |
| 1143 | - $language = icl_get_languages(); | |
| 1144 | - $current_lang = icl_get_current_language(); | |
| 1145 | - $default_lang = icl_get_default_language(); | |
| 1146 | - $post_info = wpml_get_language_information( null, $chart_id ); | |
| 1147 | - $translations = array(); | |
| 1148 | - if ( ! empty( $post_info ) && ( $default_lang === $post_info['language_code'] ) ) { | |
| 1149 | - $trid = $sitepress->get_element_trid( $chart_id, 'post_' . Visualizer_Plugin::CPT_VISUALIZER ); | |
| 1150 | - $translations = $sitepress->get_element_translations( $trid ); | |
| 1151 | - } | |
| 1152 | - if ( empty( $translations ) ) { | |
| 1153 | - return; | |
| 1154 | - } | |
| 1155 | - ?> | |
| 1156 | - <hr><div class="visualizer-languages-list only-pro"> | |
| 1157 | - <?php | |
| 1158 | - foreach ( $language as $lang ) { | |
| 1159 | - $lang_code = $lang['code']; | |
| 1160 | - if ( $current_lang !== $lang_code ) { | |
| 1161 | - ?> | |
| 1162 | - <a href="javascript:;"> | |
| 1163 | - <img src="<?php echo esc_url( $lang['country_flag_url'] ); ?>" alt="<?php echo esc_attr( $lang['translated_name'] ); ?>"> | |
| 1164 | - </a> | |
| 1165 | - <?php | |
| 1166 | - } | |
| 1167 | - } | |
| 1168 | - ?> | |
| 1169 | - <a href="<?php echo tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'wpml-support', 'visualizer_render_char' ); ?>"target="_blank"><?php esc_html_e( 'Upgrade to PRO to active this translation for charts', 'visualizer' ); ?></a> | |
| 1170 | - </div> | |
| 1171 | - <?php | |
| 1172 | - } | |
| 1173 | - } | |
| 1174 | - | |
| 1175 | - /** | |
| 1176 | - * Check chart is enabled or not. | |
| 1177 | - * | |
| 1178 | - * @param string $type Chart ID. | |
| 1179 | - * | |
| 1180 | - * @return bool Default false | |
| 1181 | - */ | |
| 1182 | - public static function checkChartStatus( $type ) { | |
| 1183 | - $types = self::_getChartTypesLocalized( false, false, false, true ); | |
| 1184 | - if ( isset( $types[ $type ] ) ) { | |
| 1185 | - return ! empty( $types[ $type ]['enabled'] ); | |
| 1186 | - } | |
| 1187 | - return false; | |
| 1188 | - } | |
| 1189 | - | |
| 1190 | - /** | |
| 1191 | - * Get the survey metadata. | |
| 1192 | - * | |
| 1193 | - * @return array The survey metadata. | |
| 1194 | - */ | |
| 1195 | - private function get_survey_metadata() { | |
| 1196 | - $install_date = get_option( 'visualizer_install', false ); | |
| 1197 | - $install_category = 0; | |
| 1198 | - | |
| 1199 | - if ( false !== $install_date ) { | |
| 1200 | - $days_since_install = round( ( time() - $install_date ) / DAY_IN_SECONDS ); | |
| 1201 | - | |
| 1202 | - if ( 0 === $days_since_install || 1 === $days_since_install ) { | |
| 1203 | - $install_category = 0; | |
| 1204 | - } elseif ( 1 < $days_since_install && 8 > $days_since_install ) { | |
| 1205 | - $install_category = 7; | |
| 1206 | - } elseif ( 8 <= $days_since_install && 31 > $days_since_install ) { | |
| 1207 | - $install_category = 30; | |
| 1208 | - } elseif ( 30 < $days_since_install && 90 > $days_since_install ) { | |
| 1209 | - $install_category = 90; | |
| 1210 | - } elseif ( 90 <= $days_since_install ) { | |
| 1211 | - $install_category = 91; | |
| 1212 | - } | |
| 1213 | - } | |
| 1214 | - | |
| 1215 | - $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false ); | |
| 1216 | - $plugin_version = ''; | |
| 1217 | - if ( ! empty( $plugin_data['Version'] ) ) { | |
| 1218 | - $plugin_version = $plugin_data['Version']; | |
| 1219 | - } | |
| 1220 | - | |
| 1221 | - $user_id = 'visualizer_' . preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID. | |
| 1222 | - | |
| 1223 | - $license_data = get_option( 'visualizer_pro_license_data', false ); | |
| 1224 | - if ( false !== $license_data ) { | |
| 1225 | - $user_id = 'visualizer_' . $license_data->key; | |
| 1226 | - } | |
| 1227 | - | |
| 1228 | - return array( | |
| 1229 | - 'userId' => $user_id, | |
| 1230 | - 'attributes' => array( | |
| 1231 | - 'days_since_install' => $install_category, | |
| 1232 | - 'free_version' => $plugin_version, | |
| 1233 | - 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '', | |
| 1234 | - 'license_status' => apply_filters( 'product_visualizer_license_status', 'invalid' ), | |
| 1235 | - ), | |
| 1236 | - ); | |
| 1237 | - } | |
| 1238 | - | |
| 1239 | - /** | |
| 1240 | - * Load the survey. | |
| 1241 | - */ | |
| 1242 | - private function load_survey() { | |
| 1243 | - | |
| 1244 | - if ( defined( 'TI_CYPRESS_TESTING' ) ) { | |
| 1245 | - return; | |
| 1246 | - } | |
| 1247 | - | |
| 1248 | - $survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' ); | |
| 1249 | - | |
| 1250 | - if ( empty( $survey_handler ) ) { | |
| 1251 | - return; | |
| 1252 | - } | |
| 1253 | - | |
| 1254 | - $metadata = $this->get_survey_metadata(); | |
| 1255 | - | |
| 1256 | - do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' ); | |
| 1257 | - wp_enqueue_script( 'visualizer_chart_survey', VISUALIZER_ABSURL . 'js/survey.js', array( $survey_handler ), $metadata['attributes']['free_version'], true ); | |
| 1258 | - wp_localize_script( 'visualizer_chart_survey', 'visualizerSurveyData', $metadata ); | |
| 1259 | 1107 | } |
| 1260 | 1108 | } |