| @@ -5,13 +5,25 @@ | ||
| 5 | 5 | * @since v.2.0 |
| 6 | 6 | * |
| 7 | 7 | * @return void |
| 8 | 8 | */ |
| 9 | -function wppb_register_your_version_submenu_page() { | |
| 10 | - if ( PROFILE_BUILDER != 'Profile Builder Free' ) | |
| 11 | - add_submenu_page( 'profile-builder', __( 'Register Your Version', 'profilebuilder' ), __( 'Register Version', 'profilebuilder' ), 'manage_options', 'profile-builder-register', 'wppb_register_your_version_content' ); | |
| 9 | + | |
| 10 | +if( !is_multisite() ){ | |
| 11 | + function wppb_register_your_version_submenu_page() | |
| 12 | + { | |
| 13 | + if (PROFILE_BUILDER != 'Profile Builder Free') | |
| 14 | + add_submenu_page('profile-builder', __('Register Your Version', 'profile-builder'), __('Register Version', 'profile-builder'), 'manage_options', 'profile-builder-register', 'wppb_register_your_version_content'); | |
| 15 | + } | |
| 16 | + add_action('admin_menu', 'wppb_register_your_version_submenu_page', 20); | |
| 12 | 17 | } |
| 13 | -add_action( 'admin_menu', 'wppb_register_your_version_submenu_page', 20 ); | |
| 18 | +else{ | |
| 19 | + function wppb_multisite_register_your_version_page() | |
| 20 | + { | |
| 21 | + if (PROFILE_BUILDER != 'Profile Builder Free') | |
| 22 | + add_menu_page(__('Profile Builder Register', 'profile-builder'), __('Profile Builder Register', 'profile-builder'), 'manage_options', 'profile-builder-register', 'wppb_register_your_version_content', WPPB_PLUGIN_URL . 'assets/images/pb-menu-icon.png'); | |
| 23 | + } | |
| 24 | + add_action('network_admin_menu', 'wppb_multisite_register_your_version_page', 20); | |
| 25 | +} | |
| 14 | 26 | |
| 15 | 27 | |
| 16 | 28 | /** |
| 17 | 29 | * Function that adds content to the "Register your Version" submenu page |
| @@ -45,33 +57,35 @@ | ||
| 45 | 57 | */ |
| 46 | 58 | function wppb_serial_form($version, $fullname){ |
| 47 | 59 | ?> |
| 48 | 60 | |
| 49 | - <h2><?php _e( "Register your version of $fullname", 'profilebuilder' ); ?></h2> | |
| 61 | + <h2><?php _e( "Register your version of $fullname", 'profile-builder' ); ?></h2> | |
| 50 | 62 | |
| 51 | - <form method="post" action="options.php"> | |
| 63 | + <form method="post" action="<?php echo get_admin_url( 1, 'options.php' ) ?>"> | |
| 52 | 64 | |
| 53 | 65 | <?php $wppb_profile_builder_serial = get_option( 'wppb_profile_builder_'.$version.'_serial' ); ?> |
| 54 | 66 | <?php $wppb_profile_builder_serial_status = get_option( 'wppb_profile_builder_'.$version.'_serial_status' ); ?> |
| 55 | 67 | <?php settings_fields( 'wppb_profile_builder_'.$version.'_serial' ); ?> |
| 56 | 68 | |
| 57 | - <p><?php _e( "Now that you acquired a copy of $fullname, you should take the time and register it with the serial number you received", 'profilebuilder' );?></p> | |
| 58 | - <p><?php _e( "If you register this version of Profile Builder, you'll receive information regarding upgrades, patches, and technical support.", 'profilebuilder' );?></p> | |
| 69 | + <p><?php printf( __( "Now that you acquired a copy of %s, you should take the time and register it with the serial number you received", 'profile-builder'), $fullname);?></p> | |
| 70 | + <p><?php _e( "If you register this version of Profile Builder, you'll receive information regarding upgrades, patches, and technical support.", 'profile-builder' );?></p> | |
| 59 | 71 | <p class="wppb-serial-wrap"> |
| 60 | - <label for="wppb_profile_builder_<?php echo $version; ?>_serial"><?php _e(' Serial Number:', 'profilebuilder' );?></label> | |
| 61 | - <input type="text" size="50" name="wppb_profile_builder_<?php echo $version; ?>_serial" id="wppb_profile_builder_<?php echo $version; ?>_serial" class="regular-text" <?php if ( $wppb_profile_builder_serial != ''){ echo ' value="'.$wppb_profile_builder_serial.'"';} ?>/> | |
| 72 | + <label for="wppb_profile_builder_<?php echo $version; ?>_serial"><?php _e(' Serial Number:', 'profile-builder' );?></label> | |
| 73 | + <input type="password" size="50" name="wppb_profile_builder_<?php echo $version; ?>_serial" id="wppb_profile_builder_<?php echo $version; ?>_serial" class="regular-text" <?php if ( $wppb_profile_builder_serial != ''){ echo ' value="'.$wppb_profile_builder_serial.'"';} ?>/> | |
| 62 | 74 | |
| 63 | 75 | <?php |
| 64 | 76 | if( $wppb_profile_builder_serial_status == 'found' ) |
| 65 | - echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/accept.png" title="'.__( 'The serial number was successfully validated!', 'profilebuilder' ).'"/></span>'; | |
| 77 | + echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/accept.png" title="'.__( 'The serial number was successfully validated!', 'profile-builder' ).'"/></span>'; | |
| 66 | 78 | elseif ( $wppb_profile_builder_serial_status == 'notFound' ) |
| 67 | - echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number entered couldn\'t be validated!','profilebuilder' ).'"/></span>'; | |
| 79 | + echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number entered couldn\'t be validated!','profile-builder' ).'"/></span>'; | |
| 80 | + elseif ( strpos( $wppb_profile_builder_serial_status, 'aboutToExpire') !== false ) | |
| 81 | + echo '<span class="validateStatus"><img src="' . WPPB_PLUGIN_URL . '/assets/images/icon_error.png" title="' . __('The serial number is about to expire soon!', 'profile-builder') . '"/>'. sprintf( __(' Your serial number is about to expire, please %1$s Renew Your License%2$s.','profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' >", "</a>").'</span>'; | |
| 68 | 82 | elseif ( $wppb_profile_builder_serial_status == 'expired' ) |
| 69 | - echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because it expired!','profilebuilder' ).'"/></span>'; | |
| 83 | + echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because it expired!','profile-builder' ).'"/>'. sprintf( __(' Your serial number is expired, please %1$s Renew Your License%2$s.','profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' >", "</a>").'</span>'; | |
| 70 | 84 | elseif ( $wppb_profile_builder_serial_status == 'serverDown' ) |
| 71 | - echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because process timed out. This is possible due to the server being down. Please try again later!','profilebuilder' ).'"/></span>'; | |
| 85 | + echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because process timed out. This is possible due to the server being down. Please try again later!','profile-builder' ).'"/></span>'; | |
| 72 | 86 | ?> |
| 73 | - <span class="wppb-serialnumber-descr"><?php _e( '(e.g. RMPB-15-SN-253a55baa4fbe7bf595b2aabb8d72985)', 'profilebuilder' );?></span> | |
| 87 | + <span class="wppb-serialnumber-descr"><?php _e( '(e.g. RMPB-15-SN-253a55baa4fbe7bf595b2aabb8d72985)', 'profile-builder' );?></span> | |
| 74 | 88 | </p> |
| 75 | 89 | |
| 76 | 90 | |
| 77 | 91 | <div id="wppb_submit_button_div"> |
| @@ -90,11 +104,11 @@ | ||
| 90 | 104 | //the function to check the validity of the serial number and save a variable in the DB; purely visual |
| 91 | 105 | function wppb_check_serial_number($oldVal, $newVal){ |
| 92 | 106 | |
| 93 | 107 | $serial_number_set = $newVal; |
| 94 | - | |
| 108 | + | |
| 109 | + | |
| 95 | 110 | $response = wp_remote_get( 'http://updatemetadata.cozmoslabs.com/checkserial/?serialNumberSent='.$serial_number_set ); |
| 96 | - | |
| 97 | 111 | if ( PROFILE_BUILDER == 'Profile Builder Pro' ){ |
| 98 | 112 | wppb_update_serial_status($response, 'pro'); |
| 99 | 113 | wp_clear_scheduled_hook( "check_plugin_updates-profile-builder-pro-update" ); |
| 100 | 114 | } else { |
| @@ -118,9 +132,9 @@ | ||
| 118 | 132 | function wppb_update_serial_status($response, $version) |
| 119 | 133 | { |
| 120 | 134 | if (is_wp_error($response)) { |
| 121 | 135 | update_option('wppb_profile_builder_'.$version.'_serial_status', 'serverDown'); //server down |
| 122 | - } elseif ((trim($response['body']) != 'notFound') && (trim($response['body']) != 'found') && (trim($response['body']) != 'expired')) { | |
| 136 | + } elseif ((trim($response['body']) != 'notFound') && (trim($response['body']) != 'found') && (trim($response['body']) != 'expired') && (strpos( $response['body'], 'aboutToExpire' ) === false)) { | |
| 123 | 137 | update_option('wppb_profile_builder_'.$version.'_serial_status', 'serverDown'); //unknown response parameter |
| 124 | 138 | update_option('wppb_profile_builder_'.$version.'_serial', ''); //reset the entered password, since the user will need to try again later |
| 125 | 139 | |
| 126 | 140 | } else { |
| @@ -205,21 +219,34 @@ | ||
| 205 | 219 | do_action( $this->pluginPrefix.'_after_notification_dismissed', $current_user ); |
| 206 | 220 | } |
| 207 | 221 | } |
| 208 | 222 | |
| 223 | +if( is_multisite() && function_exists( 'switch_to_blog' ) ) | |
| 224 | + switch_to_blog(1); | |
| 225 | + | |
| 209 | 226 | if ( PROFILE_BUILDER == 'Profile Builder Pro' ){ |
| 210 | 227 | $wppb_profile_builder_pro_hobbyist_serial_status = get_option( 'wppb_profile_builder_pro_serial_status', 'empty' ); |
| 228 | + $version = 'pro'; | |
| 229 | + | |
| 211 | 230 | } elseif( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) { |
| 212 | 231 | $wppb_profile_builder_pro_hobbyist_serial_status = get_option( 'wppb_profile_builder_hobbyist_serial_status', 'empty' ); |
| 232 | + $version = 'hobbyist'; | |
| 213 | 233 | } |
| 234 | +if( is_multisite() && function_exists( 'restore_current_blog' ) ) | |
| 235 | + restore_current_blog(); | |
| 214 | 236 | |
| 215 | 237 | if ( $wppb_profile_builder_pro_hobbyist_serial_status == 'notFound' || $wppb_profile_builder_pro_hobbyist_serial_status == 'empty' ){ |
| 216 | - new wppb_add_notices( 'wppb', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s of Profile Builder to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s</p>', 'profilebuilder'), "<a href='admin.php?page=profile-builder-register'>", "</a>", "<a href='http://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Purchase' target='_blank' class='button-primary'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' ); | |
| 238 | + if( !is_multisite() ) | |
| 239 | + $register_url = 'admin.php?page=profile-builder-register'; | |
| 240 | + else | |
| 241 | + $register_url = network_admin_url( 'admin.php?page=profile-builder-register' ); | |
| 242 | + | |
| 243 | + new wppb_add_notices( 'wppb', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s</p>', 'profile-builder'), "<a href='". $register_url ."'>", "</a>", "<a href='https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-SN-Purchase' target='_blank' class='button-primary'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' ); | |
| 217 | 244 | } |
| 218 | 245 | elseif ( $wppb_profile_builder_pro_hobbyist_serial_status == 'expired' ){ |
| 219 | - $wppb_notice = new wppb_add_notices( 'wppb', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> licence has expired. <br/>Please %1$sRenew Your Licence%2$s to receive access to automatic updates and support. %3$sPurchase one now%4$s %5$sDismiss%6$s</p>', 'profilebuilder'), "<a href='http://www.cozmoslabs.com/downloads/profile-builder-pro-1-year/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='http://www.cozmoslabs.com/downloads/profile-builder-pro-1-year/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", "<a href='". add_query_arg( 'wppb_dismiss_notification', '0' ) ."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' ); | |
| 246 | + new wppb_add_notices( 'wppb_expired', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now and get 40% off %4$s %5$sDismiss%6$s</p>', 'profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/downloads/profile-builder-".$version."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", "<a href='". esc_url( add_query_arg( 'wppb_expired_dismiss_notification', '0' ) ) ."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' ); | |
| 220 | 247 | } |
| 221 | 248 | elseif( strpos( $wppb_profile_builder_pro_hobbyist_serial_status, 'aboutToExpire' ) === 0 ){ |
| 222 | 249 | $serial_status_parts = explode( '#', $wppb_profile_builder_pro_hobbyist_serial_status ); |
| 223 | 250 | $date = $serial_status_parts[1]; |
| 224 | - new wppb_add_notices( 'wppb', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> serial number is about to expire on %5$s. <br/>Please %1$sRenew Your Licence%2$s to receive access to automatic updates and support. %3$sPurchase one now%4$s</p>', 'profilebuilder'), "<a href='admin.php?page=profile-builder-register'>", "</a>", "<a href='http://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Purchase' target='_blank' class='button-primary'>", "</a>", $date ), 'wppb_profile_builder_pro_serial_status' ); | |
| 251 | + new wppb_add_notices( 'wppb_about_to_expire', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> license is about to expire on %5$s. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now and get 40% off %4$s %6$sDismiss%7$s</p>', 'profile-builder'), "<a href='https://www.cozmoslabs.com/downloads/profile-builder-". $version ."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/downloads/profile-builder-".$version."-v2-yearly-renewal/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", $date, "<a href='". esc_url( add_query_arg( 'wppb_about_to_expire_dismiss_notification', '0' ) )."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' ); | |
| 225 | 252 | } |