88 $this->is_network_options = $args['is_network_options']; |
89 $this->is_network_options = $args['is_network_options']; |
89 |
90 |
90 $this->doc_link = $args['doc_link']; |
91 $this->doc_link = $args['doc_link']; |
91 $this->doc_video_link = $args['doc_video_link']; |
92 $this->doc_video_link = $args['doc_video_link']; |
92 |
93 |
93 $this->pro_page = $args['pro_page']; |
|
94 $this->bws_license_plugin = $args['bws_license_plugin']; |
|
95 $this->link_key = $args['link_key']; |
94 $this->link_key = $args['link_key']; |
96 $this->link_pn = $args['link_pn']; |
95 $this->link_pn = $args['link_pn']; |
97 $this->trial_days = $args['trial_days']; |
96 $this->trial_days = $args['trial_days']; |
98 $this->licenses = $args['licenses']; |
97 $this->licenses = $args['licenses']; |
99 |
98 |
100 $this->hide_pro_tabs = bws_hide_premium_options_check( $this->options ); |
99 $this->pro_page = $this->bws_license_plugin = ''; |
|
100 /* get $bws_plugins */ |
|
101 require( dirname( __FILE__ ) . '/product_list.php' ); |
|
102 if ( isset( $bws_plugins[ $this->plugin_basename ] ) ) { |
|
103 if ( isset( $bws_plugins[ $this->plugin_basename ]['pro_settings'] ) ) { |
|
104 $this->pro_page = $bws_plugins[ $this->plugin_basename ]['pro_settings']; |
|
105 $this->bws_license_plugin = $bws_plugins[ $this->plugin_basename ]['pro_version']; |
|
106 } |
|
107 |
|
108 $this->bws_plugin_link = substr( $bws_plugins[ $this->plugin_basename ]['link'],0 , strpos( $bws_plugins[ $this->plugin_basename ]['link'], '?' ) ); |
|
109 |
|
110 if ( ! empty( $this->link_key ) && ! empty( $this->link_pn ) ) |
|
111 $this->bws_plugin_link .= '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version; |
|
112 } |
|
113 |
|
114 $this->hide_pro_tabs = bws_hide_premium_options_check( $this->options ); |
101 $this->version = '1.0.0'; |
115 $this->version = '1.0.0'; |
102 $this->is_multisite = is_multisite(); |
116 $this->is_multisite = is_multisite(); |
103 |
117 |
104 if ( empty( $this->pro_page ) && array_key_exists( 'license', $this->tabs ) ) { |
118 if ( empty( $this->pro_page ) && array_key_exists( 'license', $this->tabs ) ) { |
105 $this->is_pro = true; |
119 $this->is_pro = true; |
154 <div class="inside"> |
168 <div class="inside"> |
155 <div class="submitbox" id="submitpost"> |
169 <div class="submitbox" id="submitpost"> |
156 <div id="minor-publishing"> |
170 <div id="minor-publishing"> |
157 <div id="misc-publishing-actions"> |
171 <div id="misc-publishing-actions"> |
158 <?php if ( $this->is_pro ) { |
172 <?php if ( $this->is_pro ) { |
159 if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) || isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $this->plugin_basename ] ) ) { |
173 if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $this->plugin_basename ] ) || empty( $bstwbsftwppdtplgns_options['time_out'] ) || ! array_key_exists( $this->plugin_basename, $bstwbsftwppdtplgns_options['time_out'] ) ) { |
160 $license_type = 'Pro'; |
174 $license_type = 'Pro'; |
161 $license_status = __( 'Inactive', 'bestwebsoft' ) . ' <a href="#' . $this->prefix . '_license_tab" class="bws_trigger_tab_click">' . __( 'Learn More', 'bestwebsoft' ) . '</a>'; |
175 $license_status = __( 'Inactive', 'bestwebsoft' ) . ' <a href="#' . $this->prefix . '_license_tab" class="bws_trigger_tab_click">' . __( 'Learn More', 'bestwebsoft' ) . '</a>'; |
162 } else { |
176 } else { |
163 $finish = strtotime( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ); |
177 $finish = strtotime( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ); |
164 $today = strtotime( date( "m/d/Y" ) ); |
178 $today = strtotime( date( "m/d/Y" ) ); |
172 $license_status = sprintf( __( '%s day(-s) left', 'bestwebsoft' ), $daysleft ); |
186 $license_status = sprintf( __( '%s day(-s) left', 'bestwebsoft' ), $daysleft ); |
173 } |
187 } |
174 $license_status .= '. <a target="_blank" href="' . esc_url( $this->plugins_info['PluginURI'] ) . '">' . __( 'Upgrade to Pro', 'bestwebsoft' ) . '</a>'; |
188 $license_status .= '. <a target="_blank" href="' . esc_url( $this->plugins_info['PluginURI'] ) . '">' . __( 'Upgrade to Pro', 'bestwebsoft' ) . '</a>'; |
175 } else { |
189 } else { |
176 $license_type = isset( $bstwbsftwppdtplgns_options['nonprofit'][ $this->plugin_basename ] ) ? 'Nonprofit Pro' : 'Pro'; |
190 $license_type = isset( $bstwbsftwppdtplgns_options['nonprofit'][ $this->plugin_basename ] ) ? 'Nonprofit Pro' : 'Pro'; |
177 if ( $finish < $today ) { |
191 if ( ! empty( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) && $finish < $today ) { |
178 $license_status = sprintf( __( 'Expired on %s', 'bestwebsoft' ), $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) . '. <a target="_blank" href="https://support.bestwebsoft.com/entries/53487136">' . __( 'Renew Now', 'bestwebsoft' ) . '</a>'; |
192 $license_status = sprintf( __( 'Expired on %s', 'bestwebsoft' ), $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) . '. <a target="_blank" href="https://support.bestwebsoft.com/entries/53487136">' . __( 'Renew Now', 'bestwebsoft' ) . '</a>'; |
179 } else { |
193 } else { |
180 $license_status = __( 'Active', 'bestwebsoft' ); |
194 $license_status = __( 'Active', 'bestwebsoft' ); |
181 } |
195 } |
182 } |
196 } |
450 $list = array( |
463 $list = array( |
451 'css' => array( 'description' => __( 'These styles will be added to the header on all pages of your site.', 'bestwebsoft' ), |
464 'css' => array( 'description' => __( 'These styles will be added to the header on all pages of your site.', 'bestwebsoft' ), |
452 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started' |
465 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started' |
453 ), |
466 ), |
454 'php' => array( 'description' => sprintf( __( 'This PHP code will be hooked to the %s action and will be printed on front end only.', 'bestwebsoft' ), '<a href="https://codex.wordpress.org/Plugin_API/Action_Reference/init" target="_blank"><code>init</code></a>' ), |
467 'php' => array( 'description' => sprintf( __( 'This PHP code will be hooked to the %s action and will be printed on front end only.', 'bestwebsoft' ), '<a href="https://codex.wordpress.org/Plugin_API/Action_Reference/init" target="_blank"><code>init</code></a>' ), |
455 'learn_more_link' => 'http://php.net/' |
468 'learn_more_link' => 'https://php.net/' |
456 ), |
469 ), |
457 'js' => array( 'description' => __( 'These code will be added to the header on all pages of your site.', 'bestwebsoft' ), |
470 'js' => array( 'description' => __( 'These code will be added to the header on all pages of your site.', 'bestwebsoft' ), |
458 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript' |
471 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript' |
459 ), |
472 ), |
460 ); |
473 ); |
720 global $wp_version, $bstwbsftwppdtplgns_options; ?> |
735 global $wp_version, $bstwbsftwppdtplgns_options; ?> |
721 <h3 class="bws_tab_label"><?php _e( 'License Key', 'bestwebsoft' ); ?></h3> |
736 <h3 class="bws_tab_label"><?php _e( 'License Key', 'bestwebsoft' ); ?></h3> |
722 <?php $this->help_phrase(); ?> |
737 <?php $this->help_phrase(); ?> |
723 <hr> |
738 <hr> |
724 <?php |
739 <?php |
725 foreach ( $this->licenses as $single_license) { |
740 foreach ( $this->licenses as $single_license ) { |
726 $pro_plugin_name = ( strpos( $single_license['name'], 'Pro' ) ) ? $single_license['name'] : $single_license['name'] . ' ' . 'Pro'; |
741 $pro_plugin_name = ( strpos( $single_license['name'], 'Pro' ) ) ? $single_license['name'] : $single_license['name'] . ' ' . 'Pro'; |
727 if ( ! empty( $this->pro_page ) || ! empty( $single_license['pro_basename'] ) ) { |
742 if ( ! empty( $this->pro_page ) || ! empty( $single_license['pro_basename'] ) ) { |
728 |
743 |
729 if ( $this->pro_plugin_is_activated && ( empty( $single_license['pro_basename'] ) || isset( $this->bws_license_plugin ) ) ) { |
744 if ( $this->pro_plugin_is_activated && ( empty( $single_license['pro_basename'] ) || isset( $this->bws_license_plugin ) ) ) { |
730 deactivate_plugins( $single_license['basename'] ); ?> |
745 $url = 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $this->bws_license_plugin . '&bws_license_key=' . $bstwbsftwppdtplgns_options[ $this->bws_license_plugin ] . '&download_from=5'; ?> |
731 <script type="text/javascript"> |
746 <table class="form-table"> |
732 (function($) { |
747 <tr> |
733 var i = 7; |
748 <th scope="row"><?php echo $pro_plugin_name . ' License'; ?></th> |
734 function bws_set_timeout() { |
749 <td> |
735 i--; |
750 <p> |
736 if ( 0 == i ) { |
751 <strong><?php _e( 'Your Pro plugin is ready', 'bestwebsoft' ); ?></strong> |
737 window.location.href = '<?php echo esc_url( self_admin_url( $this->pro_page ) ); ?>'; |
752 <br> |
738 } else { |
753 <?php _e( 'Your plugin has been zipped, and now is ready to download.', 'bestwebsoft' ); ?> |
739 $( '#bws_timeout_counter' ).text( i ); |
754 </p> |
740 window.setTimeout( bws_set_timeout, 1000 ); |
755 <p> |
741 } |
756 <a class="button button-secondary" target="_parent" href="<?php echo esc_url( $url ); ?>"><?php _e( 'Download Now', 'bestwebsoft' ); ?></a> |
742 } |
757 </p> |
743 window.setTimeout( bws_set_timeout, 1000 ); |
758 <br> |
744 })(jQuery); |
759 <p> |
745 </script> |
760 <strong><?php _e( 'Need help installing the plugin?', 'bestwebsoft' ); ?></strong> |
746 <p><strong><?php printf( __( 'Congratulations! %s license is activated successfully.', 'bestwebsoft' ), $pro_plugin_name ); ?></strong></p> |
761 <br> |
747 <p><?php printf( __( 'You will be automatically redirected to the %s in %s seconds.', 'bestwebsoft' ), '<a href="' . esc_url( self_admin_url( $this->pro_page ) ) . '">' . __( 'Settings page', 'bestwebsoft' ) . '</a>', '<span id="bws_timeout_counter">7</span>' ); ?></p> |
762 <a target="_blank" href="https://docs.google.com/document/d/1-hvn6WRvWnOqj5v5pLUk7Awyu87lq5B_dO-Tv-MC9JQ/"><?php _e( 'How to install WordPress plugin from your admin Dashboard (ZIP archive)', 'bestwebsoft' ); ?></a> |
|
763 </p> |
|
764 <br> |
|
765 <p> |
|
766 <strong><?php _e( 'Get Started', 'bestwebsoft' ); ?></strong> |
|
767 <br> |
|
768 <a target="_blank" href="https://drive.google.com/drive/u/0/folders/0B5l8lO-CaKt9VGh0a09vUjNFNjA"><?php _e( 'Documentation', 'bestwebsoft' ); ?></a> |
|
769 <br> |
|
770 <a target="_blank" href="https://www.youtube.com/user/bestwebsoft"><?php _e( 'Video Instructions', 'bestwebsoft' ); ?></a> |
|
771 <br> |
|
772 <a target="_blank" href="https://support.bestwebsoft.com"><?php _e( 'Knowledge Base', 'bestwebsoft' ); ?></a> |
|
773 </p> |
|
774 </td> |
|
775 </tr> |
|
776 </table> |
748 <?php } else { |
777 <?php } else { |
749 $attr = ''; |
778 $attr = $license_key = ''; |
750 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] ) && |
779 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] ) && |
751 '5' < $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] && |
780 '5' < $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] && |
752 $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) |
781 $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) |
753 $attr = 'disabled="disabled"'; |
782 $attr = 'disabled="disabled"'; |
754 |
783 |
755 |
784 if ( ! empty( $single_license['pro_basename'] ) ) { |
756 $license_key = ''; |
|
757 if( ! empty( $single_license['pro_basename'] ) ) { |
|
758 $license_key = ! empty( $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] ) ? $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] : ''; |
785 $license_key = ! empty( $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] ) ? $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] : ''; |
759 } |
786 } ?> |
760 $current_plugin_link = ( ! empty( $this->link_key ) && ! empty( $this->link_pn ) ? esc_url( 'https://bestwebsoft.com/products/wordpress/plugins/' . $this->wp_slug . '/' . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version ) : esc_url( 'https://bestwebsoft.com/products/wordpress/plugins/' . $this->wp_slug . '/' ) ); |
|
761 ?> |
|
762 <table class="form-table"> |
787 <table class="form-table"> |
763 <tr> |
788 <tr> |
764 <th scope="row"><?php echo $pro_plugin_name . ' License'; ?></th> |
789 <th scope="row"><?php echo $pro_plugin_name . ' License'; ?></th> |
765 <td> |
790 <td> |
766 <input <?php echo $attr; ?> type="text" name="bws_license_key_<?php echo ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug']; ?>" value="<?php echo esc_attr( $license_key ); ?>" /> |
791 <input <?php echo $attr; ?> type="text" name="bws_license_key_<?php echo ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug']; ?>" value="<?php echo esc_attr( $license_key ); ?>" /> |
767 <input <?php echo $attr; ?> type="hidden" name="bws_license_plugin_<?php echo ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug']; ?>" value="<?php echo esc_attr( ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug'] ); ?>" /> |
792 <input <?php echo $attr; ?> type="hidden" name="bws_license_plugin_<?php echo ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug']; ?>" value="<?php echo esc_attr( ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug'] ); ?>" /> |
768 <input <?php echo $attr; ?> type="submit" class="button button-secondary" name="bws_license_submit" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> |
793 <input <?php echo $attr; ?> type="submit" class="button button-secondary" name="bws_license_submit" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> |
769 <div class="bws_info"> |
794 <div class="bws_info"> |
770 <?php printf( __( 'Enter your license key to activate %s and get premium plugin features.', 'bestwebsoft' ), '<a href="' . $current_plugin_link . '" target="_blank" title="' . $pro_plugin_name . '">' . $pro_plugin_name . '</a>' ); ?> |
795 <?php printf( __( 'Enter your license key to activate %s and get premium plugin features.', 'bestwebsoft' ), '<a href="' . $this->bws_plugin_link . '" target="_blank" title="' . $pro_plugin_name . '">' . $pro_plugin_name . '</a>' ); ?> |
771 </div> |
796 </div> |
772 <?php if ( '' != $attr ) { ?> |
797 <?php if ( '' != $attr ) { ?> |
773 <p><?php _e( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); ?></p> |
798 <p><?php _e( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); ?></p> |
774 <?php } |
799 <?php } |
775 if ( $this->trial_days !== false ) |
800 if ( $this->trial_days !== false ) |
815 * @return array The action results |
840 * @return array The action results |
816 */ |
841 */ |
817 private function save_options_license_key() { |
842 private function save_options_license_key() { |
818 global $wp_version, $bstwbsftwppdtplgns_options; |
843 global $wp_version, $bstwbsftwppdtplgns_options; |
819 /*$empty_field_error - added to avoid error when 1 field is empty while another field contains license key*/ |
844 /*$empty_field_error - added to avoid error when 1 field is empty while another field contains license key*/ |
820 $empty_field_error = ''; |
845 |
|
846 $error = $message = $empty_field_error = ''; |
|
847 |
821 foreach ( $this->licenses as $single_license) { |
848 foreach ( $this->licenses as $single_license) { |
822 $bws_license_key = ( isset( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) ? stripslashes( sanitize_text_field( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) : ''; |
849 $bws_license_key = ( isset( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) ? stripslashes( sanitize_text_field( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) : ''; |
823 if ( '' != $bws_license_key ) { |
850 if ( '' != $bws_license_key ) { |
824 if ( strlen( $bws_license_key ) != 18 ) { |
851 if ( strlen( $bws_license_key ) != 18 ) { |
825 $error = __( 'Wrong license key', 'bestwebsoft' ); |
852 $error = __( 'Wrong license key', 'bestwebsoft' ); |
836 } |
863 } |
837 $current = get_site_transient( 'update_plugins' ); |
864 $current = get_site_transient( 'update_plugins' ); |
838 |
865 |
839 if ( ! empty( $this->all_plugins ) && ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
866 if ( ! empty( $this->all_plugins ) && ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
840 $to_send = array(); |
867 $to_send = array(); |
841 $to_send["plugins"][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = $this->all_plugins[ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]; |
868 $to_send["plugins"][ $single_license['basename'] ] = $this->all_plugins[ $single_license['basename'] ]; |
842 $to_send["plugins"][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]["bws_license_key"] = $bws_license_key; |
869 $to_send["plugins"][ $single_license['basename'] ]["bws_license_key"] = $bws_license_key; |
843 $to_send["plugins"][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]["bws_illegal_client"] = true; |
870 $to_send["plugins"][ $single_license['basename'] ]["bws_illegal_client"] = true; |
844 $options = array( |
871 $options = array( |
845 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
872 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
846 'body' => array( 'plugins' => serialize( $to_send ) ), |
873 'body' => array( 'plugins' => serialize( $to_send ) ), |
847 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
874 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
848 ); |
875 ); |
849 $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); |
876 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); |
850 |
877 |
851 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
878 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
852 $error = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ': <a href=https://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); |
879 $error = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ': <a href=https://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); |
853 } else { |
880 } else { |
854 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
881 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
873 $message = __( 'The license key is valid.', 'bestwebsoft' ); |
900 $message = __( 'The license key is valid.', 'bestwebsoft' ); |
874 } |
901 } |
875 |
902 |
876 if ( ! empty( $single_response->time_out ) ) { |
903 if ( ! empty( $single_response->time_out ) ) { |
877 $message .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $single_response->time_out . '.'; |
904 $message .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $single_response->time_out . '.'; |
|
905 } else { |
|
906 /* lifetime */ |
|
907 $single_response->time_out = NULL; |
878 } |
908 } |
879 |
909 |
880 if ( isset( $single_response->trial ) && $this->is_trial ) { |
910 if ( isset( $single_response->trial ) && $this->is_trial ) { |
881 $message .= ' ' . sprintf( __( 'In order to continue using the plugin it is necessary to buy a %s license.', 'bestwebsoft' ), '<a href="' . esc_url( $this->plugins_info['PluginURI'] . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version ) . '" target="_blank" title="' . $this->plugins_info["Name"] . '">Pro</a>' ); |
911 $message .= ' ' . sprintf( __( 'In order to continue using the plugin it is necessary to buy a %s license.', 'bestwebsoft' ), '<a href="' . esc_url( $this->plugins_info['PluginURI'] . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version ) . '" target="_blank" title="' . $this->plugins_info["Name"] . '">Pro</a>' ); |
882 } |
912 } |
883 } |
913 } |
884 |
914 |
885 if ( isset( $single_response->trial ) ) { |
915 if ( isset( $single_response->trial ) ) { |
886 $bstwbsftwppdtplgns_options['trial'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = 1; |
916 $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] = 1; |
887 } else { |
917 } else { |
888 unset( $bstwbsftwppdtplgns_options['trial'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ); |
918 unset( $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] ); |
889 } |
919 } |
890 |
920 |
891 if ( isset( $single_response->nonprofit ) ) { |
921 if ( isset( $single_response->nonprofit ) ) { |
892 $bstwbsftwppdtplgns_options['nonprofit'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = 1; |
922 $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] = 1; |
893 } else { |
923 } else { |
894 unset( $bstwbsftwppdtplgns_options['nonprofit'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ); |
924 unset( $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] ); |
895 } |
925 } |
896 |
926 |
897 if ( ! isset( $bstwbsftwppdtplgns_options[ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options[ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] != $bws_license_key ) { |
927 if ( ! isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options[ $single_license['basename'] ] != $bws_license_key ) { |
898 $bstwbsftwppdtplgns_options[ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = $bws_license_key; |
928 $bstwbsftwppdtplgns_options[ $single_license['basename'] ] = $bws_license_key; |
899 |
929 |
900 $file = @fopen( dirname( dirname( __FILE__ ) ) . "/license_key.txt", "w+" ); |
930 $file = @fopen( dirname( dirname( __FILE__ ) ) . "/license_key.txt", "w+" ); |
901 if ( $file ) { |
931 if ( $file ) { |
902 @fwrite( $file, $bws_license_key ); |
932 @fwrite( $file, $bws_license_key ); |
903 @fclose( $file ); |
933 @fclose( $file ); |
904 } |
934 } |
905 $update_option = true; |
935 $update_option = true; |
906 } |
936 } |
907 |
937 |
908 if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options['time_out'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] != $single_response->time_out ) { |
938 if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ) ) { |
909 $bstwbsftwppdtplgns_options['time_out'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = $single_response->time_out; |
939 unset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ); |
910 $update_option = true; |
940 $update_option = true; |
|
941 } |
|
942 |
|
943 if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] != $single_response->time_out ) { |
|
944 $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] = $single_response->time_out; |
|
945 $update_option = true; |
911 } |
946 } |
912 |
947 |
913 if ( isset( $update_option ) ) { |
948 if ( isset( $update_option ) ) { |
914 if ( $this->is_multisite ) { |
949 if ( $this->is_multisite ) { |
915 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
950 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
953 $options = array( |
988 $options = array( |
954 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
989 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
955 'body' => array( 'plugins' => serialize( $to_send ) ), |
990 'body' => array( 'plugins' => serialize( $to_send ) ), |
956 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
991 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
957 ); |
992 ); |
958 $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); |
993 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); |
959 |
994 |
960 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
995 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
961 $error = __( "Something went wrong. Please try again later. If the error appears again, please contact us", 'bestwebsoft' ) . ': <a href="https://support.bestwebsoft.com">BestWebSoft</a>. ' . __( "We are sorry for inconvenience.", 'bestwebsoft' ); |
996 $error = __( "Something went wrong. Please try again later. If the error appears again, please contact us", 'bestwebsoft' ) . ': <a href="https://support.bestwebsoft.com">BestWebSoft</a>. ' . __( "We are sorry for inconvenience.", 'bestwebsoft' ); |
962 } else { |
997 } else { |
963 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
998 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
977 } |
1012 } |
978 if ( empty( $error ) ) { |
1013 if ( empty( $error ) ) { |
979 $bws_license_plugin = ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename']; |
1014 $bws_license_plugin = ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename']; |
980 |
1015 |
981 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
1016 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
982 |
1017 $this->pro_plugin_is_activated = true; |
983 $url = 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $bws_license_plugin . '&bws_license_key=' . $bws_license_key . '&download_from=5'; |
|
984 |
|
985 if ( ! $this->upload_dir ) { |
|
986 $this->upload_dir = wp_upload_dir(); |
|
987 } |
|
988 |
|
989 $zip_name = explode( '/', $bws_license_plugin ); |
|
990 |
|
991 if ( ! function_exists( 'curl_init' ) ) { |
|
992 $received_content = file_get_contents( $url ); |
|
993 } else { |
|
994 $ch = curl_init(); |
|
995 curl_setopt( $ch, CURLOPT_URL, $url ); |
|
996 curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
997 $received_content = curl_exec( $ch ); |
|
998 curl_close( $ch ); |
|
999 } |
|
1000 |
|
1001 if ( ! $received_content ) { |
|
1002 $error = __( "Failed to download the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
1003 } else { |
|
1004 if ( is_writable( $this->upload_dir["path"] ) ) { |
|
1005 $file_put_contents = $this->upload_dir["path"] . "/" . $zip_name[0] . ".zip"; |
|
1006 if ( file_put_contents( $file_put_contents, $received_content ) ) { |
|
1007 @chmod( $file_put_contents, octdec( 755 ) ); |
|
1008 if ( class_exists( 'ZipArchive' ) ) { |
|
1009 $zip = new ZipArchive(); |
|
1010 if ( $zip->open( $file_put_contents ) === true ) { |
|
1011 $zip->extractTo( WP_PLUGIN_DIR ); |
|
1012 $zip->close(); |
|
1013 } else { |
|
1014 $error = __( "Failed to open the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
1015 } |
|
1016 } elseif ( class_exists( 'Phar' ) ) { |
|
1017 $phar = new PharData( $file_put_contents ); |
|
1018 $phar->extractTo( WP_PLUGIN_DIR ); |
|
1019 } else { |
|
1020 $error = __( "Your server does not support either ZipArchive or Phar. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
1021 } |
|
1022 @unlink( $file_put_contents ); |
|
1023 } else { |
|
1024 $error = __( "Failed to download the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
1025 } |
|
1026 } else { |
|
1027 $error = __( "UploadDir is not writable. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
1028 } |
|
1029 } |
|
1030 |
|
1031 /* activate Pro */ |
|
1032 if ( file_exists( WP_PLUGIN_DIR . '/' . $zip_name[0] ) ) { |
|
1033 if ( $this->is_multisite && is_plugin_active_for_network( ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ) ) { |
|
1034 /* if multisite and free plugin is network activated */ |
|
1035 $active_plugins = get_site_option( 'active_sitewide_plugins' ); |
|
1036 $active_plugins[ $bws_license_plugin ] = time(); |
|
1037 update_site_option( 'active_sitewide_plugins', $active_plugins ); |
|
1038 } else { |
|
1039 /* activate on a single blog */ |
|
1040 $active_plugins = get_option( 'active_plugins' ); |
|
1041 array_push( $active_plugins, $bws_license_plugin ); |
|
1042 update_option( 'active_plugins', $active_plugins ); |
|
1043 } |
|
1044 $this->pro_plugin_is_activated = true; |
|
1045 } elseif ( empty( $error ) ) { |
|
1046 $error = __( "Failed to download the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
1047 } |
|
1048 } |
1018 } |
1049 } else { |
1019 } else { |
1050 $error = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.", 'bestwebsoft' ); |
1020 $error = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.", 'bestwebsoft' ); |
1051 } |
1021 } |
1052 } |
1022 } |