122 bws_form_restore_default_confirm( $this->plugin_basename ); |
139 bws_form_restore_default_confirm( $this->plugin_basename ); |
123 } elseif ( isset( $_POST['bws_handle_demo'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
140 } elseif ( isset( $_POST['bws_handle_demo'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
124 $this->demo_data->bws_demo_confirm(); |
141 $this->demo_data->bws_demo_confirm(); |
125 } else { |
142 } else { |
126 bws_show_settings_notice(); ?> |
143 bws_show_settings_notice(); ?> |
127 <form class="bws_form" method="post" action="" enctype="multipart/form-data"> |
144 <form class="bws_form" method="post" action="" enctype="multipart/form-data"> |
128 <div id="poststuff"> |
145 <div id="poststuff"> |
129 <div id="post-body" class="metabox-holder columns-2"> |
146 <div id="post-body" class="metabox-holder columns-2"> |
130 <div id="post-body-content" style="position: relative;"> |
147 <div id="post-body-content" style="position: relative;"> |
131 <?php $this->display_tabs(); ?> |
148 <?php $this->display_tabs(); ?> |
132 </div><!-- #post-body-content --> |
149 </div><!-- #post-body-content --> |
133 <div id="postbox-container-1" class="postbox-container"> |
150 <div id="postbox-container-1" class="postbox-container"> |
134 <div class="meta-box-sortables ui-sortable"> |
151 <div class="meta-box-sortables ui-sortable"> |
135 <div id="submitdiv" class="postbox"> |
152 <div id="submitdiv" class="postbox"> |
136 <h3 class="hndle"><?php _e( 'Information', 'bestwebsoft' ); ?></h3> |
153 <h3 class="hndle"><?php _e( 'Information', 'bestwebsoft' ); ?></h3> |
137 <div class="inside"> |
154 <div class="inside"> |
138 <div class="submitbox" id="submitpost"> |
155 <div class="submitbox" id="submitpost"> |
139 <div id="minor-publishing"> |
156 <div id="minor-publishing"> |
140 <div id="misc-publishing-actions"> |
157 <div id="misc-publishing-actions"> |
141 <?php if ( $this->is_pro ) { |
158 <?php if ( $this->is_pro ) { |
142 if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) || isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $this->plugin_basename ] ) ) { |
159 if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) || isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $this->plugin_basename ] ) ) { |
143 $license_type = 'Pro'; |
160 $license_type = 'Pro'; |
144 $license_status = __( 'Inactive', 'bestwebsoft' ) . ' <a href="#' . $this->prefix . '_license_tab" class="bws_trigger_tab_click">' . __( 'Learn More', 'bestwebsoft' ) . '</a>'; |
161 $license_status = __( 'Inactive', 'bestwebsoft' ) . ' <a href="#' . $this->prefix . '_license_tab" class="bws_trigger_tab_click">' . __( 'Learn More', 'bestwebsoft' ) . '</a>'; |
145 } else { |
162 } else { |
146 $finish = strtotime( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ); |
163 $finish = strtotime( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ); |
147 $today = strtotime( date( "m/d/Y" ) ); |
164 $today = strtotime( date( "m/d/Y" ) ); |
148 if ( isset( $bstwbsftwppdtplgns_options['trial'][ $this->plugin_basename ] ) ) { |
165 if ( isset( $bstwbsftwppdtplgns_options['trial'][ $this->plugin_basename ] ) ) { |
149 $license_type = 'Trial Pro'; |
166 $license_type = 'Trial Pro'; |
150 |
167 |
151 if ( $finish < $today ) { |
168 if ( $finish < $today ) { |
152 $license_status = __( 'Expired', 'bestwebsoft' ); |
169 $license_status = __( 'Expired', 'bestwebsoft' ); |
153 } else { |
170 } else { |
154 $daysleft = floor( ( $finish - $today ) / ( 60*60*24 ) ); |
171 $daysleft = floor( ( $finish - $today ) / ( 60*60*24 ) ); |
155 $license_status = sprintf( __( '%s day(-s) left', 'bestwebsoft' ), $daysleft ); |
172 $license_status = sprintf( __( '%s day(-s) left', 'bestwebsoft' ), $daysleft ); |
156 } |
173 } |
157 $license_status .= '. <a target="_blank" href="' . esc_url( $this->plugins_info['PluginURI'] ) . '">' . __( 'Upgrade to Pro', 'bestwebsoft' ) . '</a>'; |
174 $license_status .= '. <a target="_blank" href="' . esc_url( $this->plugins_info['PluginURI'] ) . '">' . __( 'Upgrade to Pro', 'bestwebsoft' ) . '</a>'; |
158 } else { |
175 } else { |
159 $license_type = isset( $bstwbsftwppdtplgns_options['nonprofit'][ $this->plugin_basename ] ) ? 'Nonprofit Pro' : 'Pro'; |
176 $license_type = isset( $bstwbsftwppdtplgns_options['nonprofit'][ $this->plugin_basename ] ) ? 'Nonprofit Pro' : 'Pro'; |
160 if ( $finish < $today ) { |
177 if ( $finish < $today ) { |
161 $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>'; |
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>'; |
162 } else { |
179 } else { |
163 $license_status = __( 'Active', 'bestwebsoft' ); |
180 $license_status = __( 'Active', 'bestwebsoft' ); |
164 } |
181 } |
165 } |
182 } |
166 } ?> |
183 } ?> |
167 <div class="misc-pub-section"> |
184 <div class="misc-pub-section"> |
168 <strong><?php _e( 'License', 'bestwebsoft' ); ?>:</strong> <?php echo $license_type; ?> |
185 <strong><?php _e( 'License', 'bestwebsoft' ); ?>:</strong> <?php echo $license_type; ?> |
169 </div> |
186 </div> |
170 <div class="misc-pub-section"> |
187 <div class="misc-pub-section"> |
171 <strong><?php _e( 'Status', 'bestwebsoft' ); ?>:</strong> <?php echo $license_status; ?> |
188 <strong><?php _e( 'Status', 'bestwebsoft' ); ?>:</strong> <?php echo $license_status; ?> |
172 </div><!-- .misc-pub-section --> |
189 </div><!-- .misc-pub-section --> |
173 <?php } ?> |
190 <?php } ?> |
174 <div class="misc-pub-section"> |
191 <div class="misc-pub-section"> |
175 <strong><?php _e( 'Version', 'bestwebsoft' ); ?>:</strong> <?php echo $this->plugins_info['Version']; ?> |
192 <strong><?php _e( 'Version', 'bestwebsoft' ); ?>:</strong> <?php echo $this->plugins_info['Version']; ?> |
176 </div><!-- .misc-pub-section --> |
193 </div><!-- .misc-pub-section --> |
177 </div> |
194 </div> |
178 <div class="clear"></div> |
195 <div class="clear"></div> |
179 </div> |
196 </div> |
180 <div id="major-publishing-actions"> |
197 <div id="major-publishing-actions"> |
181 <div id="publishing-action"> |
198 <div id="publishing-action"> |
182 <input type="hidden" name="<?php echo $this->prefix; ?>_form_submit" value="submit" /> |
199 <input type="hidden" name="<?php echo $this->prefix; ?>_form_submit" value="submit" /> |
183 <input id="bws-submit-button" type="submit" class="button button-primary button-large" value="<?php _e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
200 <input id="bws-submit-button" type="submit" class="button button-primary button-large" value="<?php _e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
184 <?php wp_nonce_field( $this->plugin_basename, 'bws_nonce_name' ); ?> |
201 <?php wp_nonce_field( $this->plugin_basename, 'bws_nonce_name' ); ?> |
185 </div> |
202 </div> |
186 <div class="clear"></div> |
203 <div class="clear"></div> |
187 </div> |
204 </div> |
188 </div> |
205 </div> |
189 </div> |
206 </div> |
190 </div> |
207 </div> |
191 <?php /** |
208 <?php /** |
192 * action - Display custom metabox |
209 * action - Display custom metabox |
193 */ |
210 */ |
194 do_action( __CLASS__ . '_display_metabox' ); ?> |
211 do_action( __CLASS__ . '_display_metabox' ); ?> |
195 </div> |
212 </div> |
196 </div> |
213 </div> |
197 <div id="postbox-container-2" class="postbox-container"> |
214 <div id="postbox-container-2" class="postbox-container"> |
198 <?php /** |
215 <?php /** |
199 * action - Display additional content for #postbox-container-2 |
216 * action - Display additional content for #postbox-container-2 |
200 */ |
217 */ |
201 do_action( __CLASS__ . '_display_second_postbox' ); ?> |
218 do_action( __CLASS__ . '_display_second_postbox' ); ?> |
202 <div class="submit"> |
219 <div class="submit"> |
203 <input type="submit" class="button button-primary button-large" value="<?php _e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
220 <input type="submit" class="button button-primary button-large" value="<?php _e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
204 </div> |
221 </div> |
205 <?php if ( ! empty( $this->wp_slug ) ) |
222 <?php if ( ! empty( $this->wp_slug ) ) |
206 bws_plugin_reviews_block( $this->plugins_info['Name'], $this->wp_slug ); ?> |
223 bws_plugin_reviews_block( $this->plugins_info['Name'], $this->wp_slug ); ?> |
207 </div> |
224 </div> |
208 </div> |
225 </div> |
209 </form> |
226 </form> |
210 </div> |
227 </div> |
211 <?php } |
228 <?php } |
212 } |
229 } |
213 |
230 |
214 /** |
231 /** |
215 * Displays the Tabs |
232 * Displays the Tabs |
216 * @access public |
233 * @access public |
217 * @param void |
234 * @param void |
218 * @return void |
235 * @return void |
219 */ |
236 */ |
220 public function display_tabs() { |
237 public function display_tabs() { |
221 global $wp_version; ?> |
238 global $wp_version; ?> |
222 <div id="bws_settings_tabs_wrapper"<?php if ( version_compare( $wp_version, '4.0', '<' ) ) echo ' class="edit-form-section"'; ?>> |
239 <div id="bws_settings_tabs_wrapper"<?php if ( version_compare( $wp_version, '4.0', '<' ) ) echo ' class="edit-form-section"'; ?>> |
223 <ul id="bws_settings_tabs"> |
240 <ul id="bws_settings_tabs"> |
224 <?php $this->display_tabs_list(); ?> |
241 <?php $this->display_tabs_list(); ?> |
225 </ul> |
242 </ul> |
226 <?php $this->display_tabs_content(); ?> |
243 <?php $this->display_tabs_content(); ?> |
227 <div class="clear"></div> |
244 <div class="clear"></div> |
228 <input type="hidden" name="bws_active_tab" value="<?php if ( isset( $_REQUEST['bws_active_tab'] ) ) echo esc_attr( $_REQUEST['bws_active_tab'] ); ?>" /> |
245 <input type="hidden" name="bws_active_tab" value="<?php if ( isset( $_REQUEST['bws_active_tab'] ) ) echo esc_attr( $_REQUEST['bws_active_tab'] ); ?>" /> |
229 </div> |
246 </div> |
230 <?php } |
247 <?php } |
231 |
248 |
232 /** |
249 /** |
233 * Displays the list of tabs |
250 * Displays the list of tabs |
234 * @access private |
251 * @access private |
690 else |
709 else |
691 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
710 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
692 } |
711 } |
693 |
712 |
694 return compact( 'notice' ); |
713 return compact( 'notice' ); |
695 } |
714 } |
696 |
715 |
697 /** |
716 /** |
698 * |
717 * |
699 */ |
718 */ |
700 public function tab_license() { |
719 public function tab_license() { |
701 global $wp_version, $bstwbsftwppdtplgns_options; ?> |
720 global $wp_version, $bstwbsftwppdtplgns_options; ?> |
702 <h3 class="bws_tab_label"><?php _e( 'License Key', 'bestwebsoft' ); ?></h3> |
721 <h3 class="bws_tab_label"><?php _e( 'License Key', 'bestwebsoft' ); ?></h3> |
703 <?php $this->help_phrase(); ?> |
722 <?php $this->help_phrase(); ?> |
704 <hr> |
723 <hr> |
705 <?php if ( ! empty( $this->pro_page ) ) { |
724 <?php |
706 $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? stripslashes( sanitize_text_field( $_POST['bws_license_key'] ) ) : ""; |
725 foreach ( $this->licenses as $single_license) { |
707 |
726 $pro_plugin_name = ( strpos( $single_license['name'], 'Pro' ) ) ? $single_license['name'] : $single_license['name'] . ' ' . 'Pro'; |
708 if ( $this->pro_plugin_is_activated ) { |
727 if ( ! empty( $this->pro_page ) || ! empty( $single_license['pro_basename'] ) ) { |
709 deactivate_plugins( $this->plugin_basename ); ?> |
728 |
710 <script type="text/javascript"> |
729 if ( $this->pro_plugin_is_activated && ( empty( $single_license['pro_basename'] ) || isset( $this->bws_license_plugin ) ) ) { |
711 (function($) { |
730 deactivate_plugins( $single_license['basename'] ); ?> |
712 var i = 7; |
731 <script type="text/javascript"> |
713 function bws_set_timeout() { |
732 (function($) { |
714 i--; |
733 var i = 7; |
715 if ( 0 == i ) { |
734 function bws_set_timeout() { |
716 window.location.href = '<?php echo esc_url( self_admin_url( $this->pro_page ) ); ?>'; |
735 i--; |
717 } else { |
736 if ( 0 == i ) { |
718 $( '#bws_timeout_counter' ).text( i ); |
737 window.location.href = '<?php echo esc_url( self_admin_url( $this->pro_page ) ); ?>'; |
719 window.setTimeout( bws_set_timeout, 1000 ); |
738 } else { |
|
739 $( '#bws_timeout_counter' ).text( i ); |
|
740 window.setTimeout( bws_set_timeout, 1000 ); |
|
741 } |
720 } |
742 } |
721 } |
743 window.setTimeout( bws_set_timeout, 1000 ); |
722 window.setTimeout( bws_set_timeout, 1000 ); |
744 })(jQuery); |
723 })(jQuery); |
745 </script> |
724 </script> |
746 <p><strong><?php printf( __( 'Congratulations! %s license is activated successfully.', 'bestwebsoft' ), $pro_plugin_name ); ?></strong></p> |
725 <p><strong><?php _e( 'Congratulations! Pro license is activated successfully.', 'bestwebsoft' ); ?></strong></p> |
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> |
726 <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> |
748 <?php } else { |
727 <?php } else { |
749 $attr = ''; |
728 $attr = ''; |
750 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] ) && |
729 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] ) && |
751 '5' < $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] && |
730 '5' < $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] && |
752 $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) |
731 $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) |
753 $attr = 'disabled="disabled"'; |
732 $attr = 'disabled="disabled"'; ?> |
754 |
733 <table class="form-table"> |
755 |
734 <tr> |
756 $license_key = ''; |
735 <th scope="row"><?php _e( 'License Key', 'bestwebsoft' ); ?></th> |
757 if( ! empty( $single_license['pro_basename'] ) ) { |
736 <td> |
758 $license_key = ! empty( $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] ) ? $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] : ''; |
737 <input <?php echo $attr; ?> type="text" name="bws_license_key" value="<?php echo esc_attr( $bws_license_key ); ?>" /> |
759 } |
738 <input <?php echo $attr; ?> type="hidden" name="bws_license_plugin" value="<?php echo esc_attr( $this->bws_license_plugin ); ?>" /> |
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 . '/' ) ); |
739 <input <?php echo $attr; ?> type="submit" class="button button-secondary" name="bws_license_submit" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> |
761 ?> |
740 <div class="bws_info"> |
762 <table class="form-table"> |
741 <?php printf( __( 'Enter your license key to activate %s and get premium plugin features.', '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">' . $this->plugins_info["Name"] . ' Pro</a>' ); ?> |
763 <tr> |
742 </div> |
764 <th scope="row"><?php echo $pro_plugin_name . ' License'; ?></th> |
743 <?php if ( '' != $attr ) { ?> |
765 <td> |
744 <p><?php _e( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); ?></p> |
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 ); ?>" /> |
745 <?php } |
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'] ); ?>" /> |
746 if ( $this->trial_days !== false ) |
768 <input <?php echo $attr; ?> type="submit" class="button button-secondary" name="bws_license_submit" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> |
747 echo '<p>' . __( 'or', 'bestwebsoft' ) . ' <a href="' . esc_url( $this->plugins_info['PluginURI'] . 'trial/?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version ) . '" target="_blank">' . sprintf( __( 'Start Your Free %s-Day Trial Now', 'bestwebsoft' ), $this->trial_days ) . '</a></p>'; ?> |
769 <div class="bws_info"> |
748 </td> |
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>' ); ?> |
749 </tr> |
771 </div> |
750 </table> |
772 <?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> |
|
774 <?php } |
|
775 if ( $this->trial_days !== false ) |
|
776 echo '<p>' . __( 'or', 'bestwebsoft' ) . ' <a href="' . esc_url( $this->plugins_info['PluginURI'] . 'trial/?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version ) . '" target="_blank">' . sprintf( __( 'Start Your Free %s-Day Trial Now', 'bestwebsoft' ), $this->trial_days ) . '</a></p>'; ?> |
|
777 </td> |
|
778 </tr> |
|
779 </table> |
|
780 <?php } |
|
781 } else { |
|
782 global $bstwbsftwppdtplgns_options; |
|
783 $license_key = ( isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) ) ? $bstwbsftwppdtplgns_options[ $single_license['basename'] ] : ''; ?> |
|
784 <table class="form-table"> |
|
785 <tr> |
|
786 <th scope="row"><?php echo $pro_plugin_name . ' License'; ?></th> |
|
787 <td> |
|
788 <input type="text" maxlength="100" name="bws_license_key_<?php echo $single_license['slug']; ?>" value="<?php echo esc_attr( $license_key ); ?>" /> |
|
789 <input type="submit" class="button button-secondary" name="bws_license_submit" value="<?php _e( 'Check license key', 'bestwebsoft' ); ?>" /> |
|
790 <div class="bws_info"> |
|
791 <?php _e( 'If necessary, you can check if the license key is correct or reenter it in the field below.', 'bestwebsoft' ); ?> |
|
792 </div> |
|
793 </td> |
|
794 </tr> |
|
795 </table> |
751 <?php } |
796 <?php } |
752 } else { |
797 } ?> |
753 global $bstwbsftwppdtplgns_options; |
798 <table class="form-table"> |
754 $license_key = ( isset( $bstwbsftwppdtplgns_options[ $this->plugin_basename ] ) ) ? $bstwbsftwppdtplgns_options[ $this->plugin_basename ] : ''; ?> |
799 <tr> |
755 <table class="form-table"> |
800 <th scope="row"><?php _e( 'Manage License Settings', 'bestwebsoft' ); ?></th> |
756 <tr> |
801 <td> |
757 <th scope="row"><?php _e( 'License Key', 'bestwebsoft' ); ?></th> |
802 <a class="button button-secondary" href="https://bestwebsoft.com/client-area" target="_blank"><?php _e( 'Login to Client Area', 'bestwebsoft' ); ?></a> |
758 <td> |
803 <div class="bws_info"> |
759 <input type="text" maxlength="100" name="bws_license_key" value="<?php echo esc_attr( $license_key ); ?>" /> |
804 <?php _e( 'Manage active licenses, download BWS products, and view your payment history using BestWebSoft Client Area.', 'bestwebsoft' ); ?> |
760 <input type="submit" class="button button-secondary" name="bws_license_submit" value="<?php _e( 'Check license key', 'bestwebsoft' ); ?>" /> |
805 </div> |
761 <div class="bws_info"> |
806 </td> |
762 <?php _e( 'If necessary, you can check if the license key is correct or reenter it in the field below.', 'bestwebsoft' ); ?> |
807 </tr> |
763 </div> |
808 </table> |
764 </td> |
809 <?php } |
765 </tr> |
|
766 <tr> |
|
767 <th scope="row"><?php _e( 'Manage License Settings', 'bestwebsoft' ); ?></th> |
|
768 <td> |
|
769 <a class="button button-secondary" href="https://bestwebsoft.com/client-area" target="_blank"><?php _e( 'Login to Client Area', 'bestwebsoft' ); ?></a> |
|
770 <div class="bws_info"> |
|
771 <?php _e( 'Manage active licenses, download BWS products, and view your payment history using BestWebSoft Client Area.', 'bestwebsoft' ); ?> |
|
772 </div> |
|
773 </td> |
|
774 </tr> |
|
775 </table> |
|
776 <?php } |
|
777 } |
|
778 |
810 |
779 /** |
811 /** |
780 * Save plugin options to the database |
812 * Save plugin options to the database |
781 * @access private |
813 * @access private |
782 * @param ab |
814 * @param ab |
783 * @return array The action results |
815 * @return array The action results |
784 */ |
816 */ |
785 private function save_options_license_key() { |
817 private function save_options_license_key() { |
786 global $wp_version, $bstwbsftwppdtplgns_options; |
818 global $wp_version, $bstwbsftwppdtplgns_options; |
787 |
819 /*$empty_field_error - added to avoid error when 1 field is empty while another field contains license key*/ |
788 $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? stripslashes( sanitize_text_field( $_POST['bws_license_key'] ) ) : ''; |
820 $empty_field_error = ''; |
789 |
821 foreach ( $this->licenses as $single_license) { |
790 if ( '' != $bws_license_key ) { |
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'] ] ) ) : ''; |
791 if ( strlen( $bws_license_key ) != 18 ) { |
823 if ( '' != $bws_license_key ) { |
792 $error = __( 'Wrong license key', 'bestwebsoft' ); |
824 if ( strlen( $bws_license_key ) != 18 ) { |
793 } else { |
825 $error = __( 'Wrong license key', 'bestwebsoft' ); |
794 |
826 } else { |
795 /* CHECK license key */ |
827 |
796 if ( $this->is_pro ) { |
828 /* CHECK license key */ |
797 delete_transient( 'bws_plugins_update' ); |
829 if ( $this->is_pro && empty( $single_license['pro_basename'] ) ) { |
798 if ( ! $this->all_plugins ) { |
830 delete_transient( 'bws_plugins_update' ); |
799 if ( ! function_exists( 'get_plugins' ) ) |
831 if ( ! $this->all_plugins ) { |
800 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
832 if ( ! function_exists( 'get_plugins' ) ) { |
801 $this->all_plugins = get_plugins(); |
833 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
802 } |
|
803 $current = get_site_transient( 'update_plugins' ); |
|
804 |
|
805 if ( ! empty( $this->all_plugins ) && ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
|
806 $to_send = array(); |
|
807 $to_send["plugins"][ $this->plugin_basename ] = $this->all_plugins[ $this->plugin_basename ]; |
|
808 $to_send["plugins"][ $this->plugin_basename ]["bws_license_key"] = $bws_license_key; |
|
809 $to_send["plugins"][ $this->plugin_basename ]["bws_illegal_client"] = true; |
|
810 $options = array( |
|
811 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
|
812 'body' => array( 'plugins' => serialize( $to_send ) ), |
|
813 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
|
814 ); |
|
815 $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); |
|
816 |
|
817 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
|
818 $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' ); |
|
819 } else { |
|
820 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
821 if ( is_array( $response ) && !empty( $response ) ) { |
|
822 foreach ( $response as $single_response ) { |
|
823 if ( "wrong_license_key" == $single_response->package ) { |
|
824 $error = __( 'Wrong license key.', 'bestwebsoft' ); |
|
825 } else if ( "wrong_domain" == $single_response->package ) { |
|
826 $error = __( 'This license key is bound to another site.', 'bestwebsoft' ); |
|
827 } else if ( "time_out" == $single_response->package ) { |
|
828 $message = __( 'This license key is valid, but Your license has expired. If you want to update our plugin in future, you should extend the license.', 'bestwebsoft' ); |
|
829 } elseif ( "you_are_banned" == $single_response->package ) { |
|
830 $error = __( "Unfortunately, you have exceeded the number of available tries.", 'bestwebsoft' ); |
|
831 } elseif ( "duplicate_domen_for_trial" == $single_response->package ) { |
|
832 $error = __( "Unfortunately, the Pro Trial licence was already installed to this domain. The Pro Trial license can be installed only once.", 'bestwebsoft' ); |
|
833 } |
|
834 if ( empty( $error ) ) { |
|
835 if ( empty( $message ) ) { |
|
836 if ( isset( $single_response->trial ) ) |
|
837 $message = __( 'The Pro Trial license key is valid.', 'bestwebsoft' ); |
|
838 else |
|
839 $message = __( 'The license key is valid.', 'bestwebsoft' ); |
|
840 |
|
841 if ( ! empty( $single_response->time_out ) ) |
|
842 $message .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $single_response->time_out . '.'; |
|
843 |
|
844 if ( isset( $single_response->trial ) && $this->is_trial ) |
|
845 $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>' ); |
|
846 } |
|
847 |
|
848 if ( isset( $single_response->trial ) ) { |
|
849 $bstwbsftwppdtplgns_options['trial'][ $this->plugin_basename ] = 1; |
|
850 } else { |
|
851 unset( $bstwbsftwppdtplgns_options['trial'][ $this->plugin_basename ] ); |
|
852 } |
|
853 |
|
854 if ( isset( $single_response->nonprofit ) ) { |
|
855 $bstwbsftwppdtplgns_options['nonprofit'][ $this->plugin_basename ] = 1; |
|
856 } else { |
|
857 unset( $bstwbsftwppdtplgns_options['nonprofit'][ $this->plugin_basename ] ); |
|
858 } |
|
859 |
|
860 if ( ! isset( $bstwbsftwppdtplgns_options[ $this->plugin_basename ] ) || $bstwbsftwppdtplgns_options[ $this->plugin_basename ] != $bws_license_key ) { |
|
861 $bstwbsftwppdtplgns_options[ $this->plugin_basename ] = $bws_license_key; |
|
862 |
|
863 $file = @fopen( dirname( dirname( __FILE__ ) ) . "/license_key.txt" , "w+" ); |
|
864 if ( $file ) { |
|
865 @fwrite( $file, $bws_license_key ); |
|
866 @fclose( $file ); |
|
867 } |
|
868 $update_option = true; |
|
869 } |
|
870 |
|
871 if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) || $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] != $single_response->time_out ) { |
|
872 $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] = $single_response->time_out; |
|
873 $update_option = true; |
|
874 } |
|
875 |
|
876 if ( isset( $update_option ) ) { |
|
877 if ( $this->is_multisite ) |
|
878 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
879 else |
|
880 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
881 } |
|
882 } |
|
883 } |
|
884 } else { |
|
885 $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' ); |
|
886 } |
834 } |
|
835 $this->all_plugins = get_plugins(); |
887 } |
836 } |
888 } |
|
889 /* Go Pro */ |
|
890 } else { |
|
891 |
|
892 $bws_license_plugin = stripslashes( sanitize_text_field( $_POST['bws_license_plugin'] ) ); |
|
893 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - (24 * 60 * 60) ) ) { |
|
894 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1; |
|
895 } else { |
|
896 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1; |
|
897 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time(); |
|
898 } |
|
899 |
|
900 /* download Pro */ |
|
901 if ( ! $this->all_plugins ) { |
|
902 if ( ! function_exists( 'get_plugins' ) ) |
|
903 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
904 $this->all_plugins = get_plugins(); |
|
905 } |
|
906 |
|
907 if ( ! array_key_exists( $bws_license_plugin, $this->all_plugins ) ) { |
|
908 $current = get_site_transient( 'update_plugins' ); |
837 $current = get_site_transient( 'update_plugins' ); |
909 if ( ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
838 |
|
839 if ( ! empty( $this->all_plugins ) && ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
910 $to_send = array(); |
840 $to_send = array(); |
911 $to_send["plugins"][ $bws_license_plugin ] = 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'] ]; |
912 $to_send["plugins"][ $bws_license_plugin ]["bws_license_key"] = $bws_license_key; |
842 $to_send["plugins"][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]["bws_license_key"] = $bws_license_key; |
913 $to_send["plugins"][ $bws_license_plugin ]["bws_illegal_client"] = true; |
843 $to_send["plugins"][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]["bws_illegal_client"] = true; |
914 $options = array( |
844 $options = array( |
915 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
845 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
916 'body' => array( 'plugins' => serialize( $to_send ) ), |
846 'body' => array( 'plugins' => serialize( $to_send ) ), |
917 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ); |
847 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
|
848 ); |
918 $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); |
849 $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); |
919 |
850 |
920 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
851 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
921 $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' ); |
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' ); |
922 } else { |
853 } else { |
923 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
854 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
924 if ( is_array( $response ) && ! empty( $response ) ) { |
855 if ( is_array( $response ) && ! empty( $response ) ) { |
925 foreach ( $response as $single_response ) { |
856 foreach ( $response as $single_response ) { |
926 if ( "wrong_license_key" == $single_response->package ) { |
857 if ( "wrong_license_key" == $single_response->package ) { |
927 $error = __( "Wrong license key.", 'bestwebsoft' ); |
858 $error = __( 'Wrong license key.', 'bestwebsoft' ); |
928 } elseif ( "wrong_domain" == $single_response->package ) { |
859 } else if ( "wrong_domain" == $single_response->package ) { |
929 $error = __( "This license key is bound to another site.", 'bestwebsoft' ); |
860 $error = __( 'This license key is bound to another site.', 'bestwebsoft' ); |
|
861 } else if ( "time_out" == $single_response->package ) { |
|
862 $message = __( 'This license key is valid, but Your license has expired. If you want to update our plugin in future, you should extend the license.', 'bestwebsoft' ); |
930 } elseif ( "you_are_banned" == $single_response->package ) { |
863 } elseif ( "you_are_banned" == $single_response->package ) { |
931 $error = __( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); |
864 $error = __( "Unfortunately, you have exceeded the number of available tries.", 'bestwebsoft' ); |
932 } elseif ( "time_out" == $single_response->package ) { |
|
933 $error = sprintf( __( "Unfortunately, Your license has expired. To continue getting top-priority support and plugin updates, you should extend it in your %s.", 'bestwebsoft' ), ' <a href="https://bestwebsoft.com/client-area">Client Area</a>' ); |
|
934 } elseif ( "duplicate_domen_for_trial" == $single_response->package ) { |
865 } elseif ( "duplicate_domen_for_trial" == $single_response->package ) { |
935 $error = __( "Unfortunately, the Pro licence was already installed to this domain. The Pro Trial license can be installed only once.", 'bestwebsoft' ); |
866 $error = __( "Unfortunately, the Pro Trial licence was already installed to this domain. The Pro Trial license can be installed only once.", 'bestwebsoft' ); |
936 } |
867 } |
937 } |
868 if ( empty( $error ) ) { |
938 if ( empty( $error ) ) { |
869 if ( empty( $message ) ) { |
939 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
870 if ( isset( $single_response->trial ) ) { |
940 |
871 $message = __( 'The Pro Trial license key is valid.', 'bestwebsoft' ); |
941 $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'; |
|
942 |
|
943 if ( ! $this->upload_dir ) |
|
944 $this->upload_dir = wp_upload_dir(); |
|
945 |
|
946 $zip_name = explode( '/', $bws_license_plugin ); |
|
947 |
|
948 if ( !function_exists( 'curl_init' ) ) { |
|
949 $received_content = file_get_contents( $url ); |
|
950 } else { |
|
951 $ch = curl_init(); |
|
952 curl_setopt( $ch, CURLOPT_URL, $url ); |
|
953 curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
954 $received_content = curl_exec( $ch ); |
|
955 curl_close( $ch ); |
|
956 } |
|
957 |
|
958 if ( ! $received_content ) { |
|
959 $error = __( "Failed to download the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
960 } else { |
|
961 if ( is_writable( $this->upload_dir["path"] ) ) { |
|
962 $file_put_contents = $this->upload_dir["path"] . "/" . $zip_name[0] . ".zip"; |
|
963 if ( file_put_contents( $file_put_contents, $received_content ) ) { |
|
964 @chmod( $file_put_contents, octdec( 755 ) ); |
|
965 if ( class_exists( 'ZipArchive' ) ) { |
|
966 $zip = new ZipArchive(); |
|
967 if ( $zip->open( $file_put_contents ) === TRUE ) { |
|
968 $zip->extractTo( WP_PLUGIN_DIR ); |
|
969 $zip->close(); |
|
970 } else { |
|
971 $error = __( "Failed to open the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
972 } |
|
973 } elseif ( class_exists( 'Phar' ) ) { |
|
974 $phar = new PharData( $file_put_contents ); |
|
975 $phar->extractTo( WP_PLUGIN_DIR ); |
|
976 } else { |
|
977 $error = __( "Your server does not support either ZipArchive or Phar. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
978 } |
|
979 @unlink( $file_put_contents ); |
|
980 } else { |
872 } else { |
981 $error = __( "Failed to download the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); |
873 $message = __( 'The license key is valid.', 'bestwebsoft' ); |
982 } |
874 } |
|
875 |
|
876 if ( ! empty( $single_response->time_out ) ) { |
|
877 $message .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $single_response->time_out . '.'; |
|
878 } |
|
879 |
|
880 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>' ); |
|
882 } |
|
883 } |
|
884 |
|
885 if ( isset( $single_response->trial ) ) { |
|
886 $bstwbsftwppdtplgns_options['trial'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = 1; |
983 } else { |
887 } else { |
984 $error = __( "UploadDir is not writable. Please, upload the plugin manually.", 'bestwebsoft' ); |
888 unset( $bstwbsftwppdtplgns_options['trial'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ); |
985 } |
889 } |
986 } |
890 |
987 |
891 if ( isset( $single_response->nonprofit ) ) { |
988 /* activate Pro */ |
892 $bstwbsftwppdtplgns_options['nonprofit'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = 1; |
989 if ( file_exists( WP_PLUGIN_DIR . '/' . $zip_name[0] ) ) { |
|
990 if ( $this->is_multisite && is_plugin_active_for_network( $this->plugin_basename ) ) { |
|
991 /* if multisite and free plugin is network activated */ |
|
992 $active_plugins = get_site_option( 'active_sitewide_plugins' ); |
|
993 $active_plugins[ $bws_license_plugin ] = time(); |
|
994 update_site_option( 'active_sitewide_plugins', $active_plugins ); |
|
995 } else { |
893 } else { |
996 /* activate on a single blog */ |
894 unset( $bstwbsftwppdtplgns_options['nonprofit'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ); |
997 $active_plugins = get_option( 'active_plugins' ); |
|
998 array_push( $active_plugins, $bws_license_plugin ); |
|
999 update_option( 'active_plugins', $active_plugins ); |
|
1000 } |
895 } |
1001 $this->pro_plugin_is_activated = true; |
896 |
1002 } elseif ( empty( $error ) ) { |
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 ) { |
1003 $error = __( "Failed to download the zip archive. Please, upload the plugin manually.", 'bestwebsoft' ); |
898 $bstwbsftwppdtplgns_options[ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = $bws_license_key; |
|
899 |
|
900 $file = @fopen( dirname( dirname( __FILE__ ) ) . "/license_key.txt", "w+" ); |
|
901 if ( $file ) { |
|
902 @fwrite( $file, $bws_license_key ); |
|
903 @fclose( $file ); |
|
904 } |
|
905 $update_option = true; |
|
906 } |
|
907 |
|
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 ) { |
|
909 $bstwbsftwppdtplgns_options['time_out'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] = $single_response->time_out; |
|
910 $update_option = true; |
|
911 } |
|
912 |
|
913 if ( isset( $update_option ) ) { |
|
914 if ( $this->is_multisite ) { |
|
915 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
916 } else { |
|
917 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
918 } |
|
919 } |
1004 } |
920 } |
1005 } |
921 } |
1006 } else { |
922 } else { |
1007 $error = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.", 'bestwebsoft' ); |
923 $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' ); |
1008 } |
924 } |
1009 } |
925 } |
1010 } |
926 } |
|
927 /* Go Pro */ |
1011 } else { |
928 } else { |
1012 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
929 |
1013 /* activate Pro */ |
930 $bws_license_plugin = stripslashes( sanitize_text_field( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_plugin_' . $single_license['pro_slug'] : 'bws_license_plugin_' . $single_license['slug'] ] ) ); |
1014 if ( ! is_plugin_active( $bws_license_plugin ) ) { |
931 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { |
1015 if ( $this->is_multisite && is_plugin_active_for_network( $this->plugin_basename ) ) { |
932 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1; |
1016 /* if multisite and free plugin is network activated */ |
933 } else { |
1017 $network_wide = true; |
934 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1; |
1018 } else { |
935 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time(); |
1019 /* activate on a single blog */ |
936 } |
1020 $network_wide = false; |
937 |
|
938 /* download Pro */ |
|
939 if ( ! $this->all_plugins ) { |
|
940 if ( ! function_exists( 'get_plugins' ) ) { |
|
941 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
1021 } |
942 } |
1022 activate_plugin( $bws_license_plugin, NULL, $network_wide ); |
943 $this->all_plugins = get_plugins(); |
1023 $this->pro_plugin_is_activated = true; |
944 } |
|
945 |
|
946 if ( ! array_key_exists( $bws_license_plugin, $this->all_plugins ) ) { |
|
947 $current = get_site_transient( 'update_plugins' ); |
|
948 if ( ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
|
949 $to_send = array(); |
|
950 $to_send["plugins"][ $bws_license_plugin ] = array(); |
|
951 $to_send["plugins"][ $bws_license_plugin ]["bws_license_key"] = $bws_license_key; |
|
952 $to_send["plugins"][ $bws_license_plugin ]["bws_illegal_client"] = true; |
|
953 $options = array( |
|
954 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
|
955 'body' => array( 'plugins' => serialize( $to_send ) ), |
|
956 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
|
957 ); |
|
958 $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); |
|
959 |
|
960 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' ); |
|
962 } else { |
|
963 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
964 if ( is_array( $response ) && ! empty( $response ) ) { |
|
965 foreach ( $response as $single_response ) { |
|
966 if ( "wrong_license_key" == $single_response->package ) { |
|
967 $error = __( "Wrong license key.", 'bestwebsoft' ); |
|
968 } elseif ( "wrong_domain" == $single_response->package ) { |
|
969 $error = __( "This license key is bound to another site.", 'bestwebsoft' ); |
|
970 } elseif ( "you_are_banned" == $single_response->package ) { |
|
971 $error = __( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
972 } elseif ( "time_out" == $single_response->package ) { |
|
973 $error = sprintf( __( "Unfortunately, Your license has expired. To continue getting top-priority support and plugin updates, you should extend it in your %s.", 'bestwebsoft' ), ' <a href="https://bestwebsoft.com/client-area">Client Area</a>' ); |
|
974 } elseif ( "duplicate_domen_for_trial" == $single_response->package ) { |
|
975 $error = __( "Unfortunately, the Pro licence was already installed to this domain. The Pro Trial license can be installed only once.", 'bestwebsoft' ); |
|
976 } |
|
977 } |
|
978 if ( empty( $error ) ) { |
|
979 $bws_license_plugin = ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename']; |
|
980 |
|
981 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
|
982 |
|
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 } |
|
1049 } else { |
|
1050 $error = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.", 'bestwebsoft' ); |
|
1051 } |
|
1052 } |
|
1053 } |
|
1054 } else { |
|
1055 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
|
1056 /* activate Pro */ |
|
1057 if ( ! is_plugin_active( $bws_license_plugin ) ) { |
|
1058 if ( $this->is_multisite && is_plugin_active_for_network( ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ) ) { |
|
1059 /* if multisite and free plugin is network activated */ |
|
1060 $network_wide = true; |
|
1061 } else { |
|
1062 /* activate on a single blog */ |
|
1063 $network_wide = false; |
|
1064 } |
|
1065 activate_plugin( $bws_license_plugin, null, $network_wide ); |
|
1066 $this->pro_plugin_is_activated = true; |
|
1067 } |
|
1068 } |
|
1069 /* add 'track_usage' for Pro version */ |
|
1070 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ) && |
|
1071 empty( $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] ) ) { |
|
1072 $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] = $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]; |
|
1073 } |
|
1074 |
|
1075 if ( $this->is_multisite ) { |
|
1076 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1077 } else { |
|
1078 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1079 } |
|
1080 |
|
1081 if ( $this->pro_plugin_is_activated ) { |
|
1082 delete_transient( 'bws_plugins_update' ); |
1024 } |
1083 } |
1025 } |
1084 } |
1026 /* add 'track_usage' for Pro version */ |
|
1027 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage'][ $this->plugin_basename ] ) && |
|
1028 empty( $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] ) ) { |
|
1029 $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] = $bstwbsftwppdtplgns_options['track_usage'][ $this->plugin_basename ]; |
|
1030 } |
|
1031 |
|
1032 if ( $this->is_multisite ) |
|
1033 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1034 else |
|
1035 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1036 |
|
1037 if ( $this->pro_plugin_is_activated ) |
|
1038 delete_transient( 'bws_plugins_update' ); |
|
1039 } |
1085 } |
|
1086 } else { |
|
1087 $empty_field_error = __( "Please, enter Your license key", 'bestwebsoft' ); |
1040 } |
1088 } |
1041 } else { |
|
1042 $error = __( "Please, enter Your license key", 'bestwebsoft' ); |
|
1043 } |
1089 } |
1044 return compact( 'error', 'message' ); |
1090 return compact( 'error', 'message', 'empty_field_error' ); |
1045 } |
1091 } |
1046 |
1092 |
1047 /** |
1093 /** |
1048 * Display help phrase |
1094 * Display help phrase |
1049 * @access public |
1095 * @access public |