| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
/** |
| 4 |
* Function which returns the same field-format over and over again. |
| 5 |
* |
| 6 |
* @since v.2.0 |
| 7 |
* |
| 8 |
* @param string $field |
| 9 |
* @param string $field_title |
| 10 |
* |
| 11 |
* @return string |
| 12 |
*/ |
| 13 |
function wppb_field_format ( $field_title, $field ){ |
| 14 |
|
| 15 |
return trim( $field_title ).' ( '.trim( $field ).' )'; |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
/** |
| 20 |
* Add a notification for either the Username or the Email field letting the user know that, even though it is there, it won't do anything |
| 21 |
* |
| 22 |
* @since v.2.0 |
| 23 |
* |
| 24 |
* @param string $form |
| 25 |
* @param integer $id |
| 26 |
* @param string $value |
| 27 |
* |
| 28 |
* @return string $form |
| 29 |
*/ |
| 30 |
|
| 31 |
function wppb_manage_fields_display_field_title_slug( $form ){ |
| 32 |
// add a notice to fields |
| 33 |
global $wppb_results_field; |
| 34 |
switch ($wppb_results_field){ |
| 35 |
case 'Default - Username': |
| 36 |
$wppb_generalSettings = get_option( 'wppb_general_settings', 'not_found' ); |
| 37 |
if ( $wppb_generalSettings != 'not_found' && $wppb_generalSettings['loginWith'] == 'email' ) { |
| 38 |
$form .= '<div id="wppb-login-email-nag" class="wppb-backend-notice">' . sprintf(__('Login is set to be done using the Email. This field will NOT appear in the front-end! ( you can change these settings under the "%s" tab )', 'profile-builder'), '<a href="' . admin_url('admin.php?page=profile-builder-general-settings') . '" target="_blank">' . __('General Settings', 'profile-builder') . '</a>') . '</div>'; |
| 39 |
} |
| 40 |
break; |
| 41 |
case 'Default - Display name publicly as': |
| 42 |
$form .= '<div id="wppb-display-name-nag" class="wppb-backend-notice">' . __( 'Display name publicly as - only appears on the Edit Profile page!', 'profile-builder' ) . '</div>'; |
| 43 |
break; |
| 44 |
case 'Default - Blog Details': |
| 45 |
$form .= '<div id="wppb-blog-details-nag" class="wppb-backend-notice">' . __( 'Blog Details - only appears on the Registration page!', 'profile-builder' ) . '</div>'; |
| 46 |
break; |
| 47 |
} |
| 48 |
|
| 49 |
return $form; |
| 50 |
} |
| 51 |
|
| 52 |
add_filter( 'wck_after_content_element', 'wppb_manage_fields_display_field_title_slug' ); |
| 53 |
|
| 54 |
/** |
| 55 |
* Check if field type is 'Default - Display name publicly as' so we can add a notification for it |
| 56 |
* |
| 57 |
* @since v.2.2 |
| 58 |
* |
| 59 |
* @param string $wck_element_class |
| 60 |
* @param string $meta |
| 61 |
* @param array $results |
| 62 |
* @param integer $element_id |
| 63 |
* |
| 64 |
*/ |
| 65 |
function wppb_manage_fields_display_name_notice( $wck_element_class, $meta, $results, $element_id ) { |
| 66 |
global $wppb_results_field; |
| 67 |
|
| 68 |
$wppb_results_field = $results[$element_id]['field']; |
| 69 |
} |
| 70 |
add_filter( 'wck_element_class_wppb_manage_fields', 'wppb_manage_fields_display_name_notice', 10, 4 ); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
/** |
| 75 |
* Function that adds a custom class to the existing container |
| 76 |
* |
| 77 |
* @since v.2.0 |
| 78 |
* |
| 79 |
* @param string $update_container_class - the new class name |
| 80 |
* @param string $meta - the name of the meta |
| 81 |
* @param array $results |
| 82 |
* @param integer $element_id - the ID of the element |
| 83 |
* |
| 84 |
* @return string |
| 85 |
*/ |
| 86 |
function wppb_update_container_class( $update_container_class, $meta, $results, $element_id ) { |
| 87 |
$wppb_element_type = Wordpress_Creation_Kit_PB::wck_generate_slug( $results[$element_id]["field"] ); |
| 88 |
|
| 89 |
return "class='wck_update_container update_container_$meta update_container_$wppb_element_type element_type_$wppb_element_type'"; |
| 90 |
} |
| 91 |
add_filter( 'wck_update_container_class_wppb_manage_fields', 'wppb_update_container_class', 10, 4 ); |
| 92 |
|
| 93 |
|
| 94 |
/** |
| 95 |
* Function that adds a custom class to the existing element |
| 96 |
* |
| 97 |
* @since v.2.0 |
| 98 |
* |
| 99 |
* @param string $element_class - the new class name |
| 100 |
* @param string $meta - the name of the meta |
| 101 |
* @param array $results |
| 102 |
* @param integer $element_id - the ID of the element |
| 103 |
* |
| 104 |
* @return string |
| 105 |
*/ |
| 106 |
function wppb_element_class( $element_class, $meta, $results, $element_id ){ |
| 107 |
$wppb_element_type = Wordpress_Creation_Kit_PB::wck_generate_slug( $results[$element_id]["field"] ); |
| 108 |
|
| 109 |
return "class='element_type_$wppb_element_type added_fields_list'"; |
| 110 |
} |
| 111 |
add_filter( 'wck_element_class_wppb_manage_fields', 'wppb_element_class', 10, 4 ); |
| 112 |
|
| 113 |
/** |
| 114 |
* Functions to check password length and strength |
| 115 |
* |
| 116 |
* @since v.2.0 |
| 117 |
*/ |
| 118 |
/* on add user and update profile from WP admin area */ |
| 119 |
add_action( 'user_profile_update_errors', 'wppb_password_check_on_profile_update', 0, 3 ); |
| 120 |
function wppb_password_check_on_profile_update( $errors, $update, $user ){ |
| 121 |
wppb_password_check_extra_conditions( $errors, $user ); |
| 122 |
} |
| 123 |
|
| 124 |
/* on reset password */ |
| 125 |
add_action( 'validate_password_reset', 'wppb_password_check_extra_conditions', 10, 2 ); |
| 126 |
function wppb_password_check_extra_conditions( $errors, $user ){ |
| 127 |
$password = ( isset( $_POST[ 'pass1' ] ) && trim( $_POST[ 'pass1' ] ) ) ? $_POST[ 'pass1' ] : false; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash |
| 128 |
|
| 129 |
if( $password && ( !isset( $_POST['pw_weak'] ) || $_POST['pw_weak'] != 'on' ) ){ |
| 130 |
$wppb_generalSettings = get_option( 'wppb_general_settings' ); |
| 131 |
|
| 132 |
if( !empty( $wppb_generalSettings['minimum_password_length'] ) ){ |
| 133 |
if( strlen( $password ) < $wppb_generalSettings['minimum_password_length'] ) |
| 134 |
$errors->add( 'pass', sprintf( __( '<strong>ERROR:</strong> The password must have the minimum length of %s characters', 'profile-builder' ), $wppb_generalSettings['minimum_password_length'] ) ); |
| 135 |
} |
| 136 |
|
| 137 |
if( isset( $_POST['wppb_password_strength'] ) && !empty( $wppb_generalSettings['minimum_password_strength'] ) ){ |
| 138 |
$password_strength_array = array( 'short' => 0, 'bad' => 1, 'good' => 2, 'strong' => 3 ); |
| 139 |
$password_strength_text = array( 'short' => __( 'Very weak', 'profile-builder' ), 'bad' => __( 'Weak', 'profile-builder' ), 'good' => __( 'Medium', 'profile-builder' ), 'strong' => __( 'Strong', 'profile-builder' ) ); |
| 140 |
|
| 141 |
foreach( $password_strength_text as $psr_key => $psr_text ){ |
| 142 |
if( $psr_text == sanitize_text_field( $_POST['wppb_password_strength'] ) ){ |
| 143 |
$password_strength_result_slug = $psr_key; |
| 144 |
break; |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
if( !empty( $password_strength_result_slug ) ){ |
| 149 |
if( $password_strength_array[$password_strength_result_slug] < $password_strength_array[$wppb_generalSettings['minimum_password_strength']] ) |
| 150 |
$errors->add( 'pass', sprintf( __( '<strong>ERROR:</strong> The password must have a minimum strength of %s', 'profile-builder' ), $password_strength_text[$wppb_generalSettings['minimum_password_strength']] ) ); |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
return $errors; |
| 156 |
} |
| 157 |
|
| 158 |
/* we need to create a hidden field that contains the results of the password strength from the js strength tester */ |
| 159 |
add_action( 'admin_footer', 'wppb_add_hidden_password_strength_on_backend' ); |
| 160 |
add_action( 'login_footer', 'wppb_add_hidden_password_strength_on_backend' ); |
| 161 |
function wppb_add_hidden_password_strength_on_backend(){ |
| 162 |
if( $GLOBALS['pagenow'] == 'profile.php' || $GLOBALS['pagenow'] == 'user-new.php' || ( $GLOBALS['pagenow'] == 'wp-login.php' && isset( $_GET['action'] ) && ( $_GET['action'] === 'rp' || $_GET['action'] === 'resetpass' ) ) ){ |
| 163 |
$wppb_generalSettings = get_option( 'wppb_general_settings' ); |
| 164 |
if( !empty( $wppb_generalSettings['minimum_password_strength'] ) ){ |
| 165 |
?> |
| 166 |
<script type="text/javascript"> |
| 167 |
jQuery( document ).ready( function() { |
| 168 |
var passswordStrengthResult = jQuery( '#pass-strength-result' ); |
| 169 |
// Check for password strength meter |
| 170 |
if ( passswordStrengthResult.length ) { |
| 171 |
// Attach submit event to form |
| 172 |
passswordStrengthResult.parents( 'form' ).on( 'submit', function() { |
| 173 |
// Store check results in hidden field |
| 174 |
jQuery( this ).append( '<input type="hidden" name="wppb_password_strength" value="' + passswordStrengthResult.text() + '">' ); |
| 175 |
}); |
| 176 |
} |
| 177 |
}); |
| 178 |
</script> |
| 179 |
<?php |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
/* Modify the Add Entry buttons for WCK metaboxes according to context */ |
| 186 |
add_filter( 'wck_add_entry_button', 'wppb_change_add_entry_button', 10, 2 ); |
| 187 |
function wppb_change_add_entry_button( $string, $meta ){ |
| 188 |
if( $meta == 'wppb_manage_fields' || $meta == 'wppb_epf_fields' || $meta == 'wppb_rf_fields' ){ |
| 189 |
return __( "Add Field", 'profile-builder' ); |
| 190 |
}elseif( $meta == 'wppb_epf_page_settings' || $meta == 'wppb_rf_page_settings' || $meta == 'wppb_ul_page_settings' ){ |
| 191 |
return __( "Save Settings", 'profile-builder' ); |
| 192 |
} |
| 193 |
|
| 194 |
return $string; |
| 195 |
} |
| 196 |
|
| 197 |
/** |
| 198 |
* add links on plugin page |
| 199 |
*/ |
| 200 |
add_filter( 'plugin_action_links', 'wppb_plugin_action_links', 10, 2 ); |
| 201 |
function wppb_plugin_action_links( $links, $file ) { |
| 202 |
if ( $file != WPPB_PLUGIN_BASENAME ) { |
| 203 |
return $links; |
| 204 |
} |
| 205 |
|
| 206 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 207 |
return $links; |
| 208 |
} |
| 209 |
|
| 210 |
$settings_link = sprintf( '<a href="%1$s">%2$s</a>', |
| 211 |
menu_page_url( 'profile-builder-general-settings', false ), |
| 212 |
esc_html( __( 'Settings', 'profile-builder' ) ) ); |
| 213 |
|
| 214 |
array_unshift( $links, $settings_link ); |
| 215 |
|
| 216 |
return $links; |
| 217 |
} |
| 218 |
|
| 219 |
/** |
| 220 |
* add links on plugin page |
| 221 |
*/ |
| 222 |
add_filter( 'plugin_row_meta', 'wppb_plugin_row_meta', 10, 2 ); |
| 223 |
function wppb_plugin_row_meta( $links, $file ) { |
| 224 |
if ( WPPB_PLUGIN_BASENAME == $file ) { |
| 225 |
$row_meta = array( |
| 226 |
'docs' => '<a href="' . esc_url( 'https://www.cozmoslabs.com/docs/profile-builder/' ) . '" target="_blank" aria-label="' . esc_attr__( 'View Profile Builder documentation', 'profile-builder' ) . '">' . esc_html__( 'Docs', 'profile-builder' ) . '</a>', |
| 227 |
); |
| 228 |
|
| 229 |
return array_merge( $links, $row_meta ); |
| 230 |
} |
| 231 |
|
| 232 |
return (array) $links; |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
/* In plugin notifications */ |
| 238 |
// add_action( 'admin_init', 'wppb_add_plugin_notifications' ); |
| 239 |
// function wppb_add_plugin_notifications() { |
| 240 |
// /* initiate the plugin notifications class */ |
| 241 |
// $notifications = WPPB_Plugin_Notifications::get_instance(); |
| 242 |
// /* this must be unique */ |
| 243 |
// // $notification_id = 'wppb_migrated_free_add_ons'; |
| 244 |
|
| 245 |
// // $message = '<p style="margin-top: 16px; font-size: 15px;">' . __( 'All the free add-ons have been migrated to the main plugin. Their old individual plugins have been disabled and you can delete them from your site if you were using them: <ul><li>Profile Builder - Custom CSS Classes on fields</li><li>Profile Builder - Customization Toolbox Add-On</li><li>Profile Builder - Email Confirmation Field</li><li>Profile Builder - GDPR Communication Preferences</li><li>Profile Builder - Import and Export Add-On</li><li>Profile Builder - Labels Edit Add-On</li><li>Profile Builder - Maximum Character Length Add-On</li><li>Profile Builder - Multiple Admin E-mails Add-On</li><li>Profile Builder - Placeholder Labels Add-On</li></ul>', 'profile-builder' ) . '</p>'; |
| 246 |
// // // be careful to use wppb_dismiss_admin_notification as query arg |
| 247 |
// // $message .= '<p><a href="https://www.cozmoslabs.com/277540-profile-builder-enhancements-free-addons-now-part-of-main-plugin/" target="_blank" class="button-primary">' . __( 'See details', 'profile-builder' ) . '</a></p>'; |
| 248 |
// // $message .= '<a href="' . add_query_arg( array( 'wppb_dismiss_admin_notification' => $notification_id ) ) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'profile-builder' ) . '</span></a>'; |
| 249 |
|
| 250 |
// // $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info', false ); |
| 251 |
|
| 252 |
// if ( did_action( 'elementor/loaded' ) ) { |
| 253 |
|
| 254 |
// $notification_id = 'wppb_elementor_styling_notice'; |
| 255 |
|
| 256 |
// $message = '<img style="float: left; margin: 10px 12px 10px 0; max-width: 100px;" src="'.WPPB_PLUGIN_URL.'assets/images/elementor_logo.png" alt="Elementor Logo"/>'; |
| 257 |
// $message .= '<p style="margin: 16px 16px 0; font-size: 14px;">' . sprintf( __( 'You can now style %s forms from the %s interface. To get started, add a form widget to a page through %s and go to the <strong>Style</strong> tab.', 'profile-builder' ), '<strong>Profile Builder</strong>', '<strong>Elementor</strong>', '<strong>Elementor</strong>') . '</p>'; |
| 258 |
// // be careful to use wppb_dismiss_admin_notification as query arg |
| 259 |
// $message .= '<p><a href="https://www.cozmoslabs.com/docs/profile-builder/integration-with-elementor/" target="_blank" class="button-primary">' . __( 'See details', 'profile-builder' ) . '</a></p>'; |
| 260 |
// $message .= '<a href="' . add_query_arg( array( 'wppb_dismiss_admin_notification' => $notification_id ) ) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'profile-builder' ) . '</span></a>'; |
| 261 |
|
| 262 |
// $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info', false ); |
| 263 |
|
| 264 |
// } |
| 265 |
// } |
| 266 |
|
| 267 |
|
| 268 |
/* hook to create pages for out forms when a user press the create pages/setup button */ |
| 269 |
add_action( 'admin_init', 'wppb_create_form_pages' ); |
| 270 |
function wppb_create_form_pages(){ |
| 271 |
|
| 272 |
if( !isset( $_GET['page'] ) || $_GET['page'] != 'profile-builder-basic-info' || !isset( $_GET['wppb_create_pages'] ) || $_GET['wppb_create_pages'] != 'true' ) |
| 273 |
return; |
| 274 |
|
| 275 |
if( !isset( $_GET['_wpnonce'] ) || !wp_verify_nonce( sanitize_text_field( $_GET['_wpnonce'] ), 'wppb_create_pages' ) ) |
| 276 |
return; |
| 277 |
|
| 278 |
if( !current_user_can( 'manage_options' ) ) |
| 279 |
return; |
| 280 |
|
| 281 |
$wppb_pages_created = get_option( 'wppb_pages_created' ); |
| 282 |
|
| 283 |
if( empty( $wppb_pages_created ) || ( isset( $_GET['wppb_force_create_pages'] ) && $_GET['wppb_force_create_pages'] === 'true' ) ) { |
| 284 |
$register_page = array( |
| 285 |
'post_title' => 'Register', |
| 286 |
'post_content' => '[wppb-register]', |
| 287 |
'post_status' => 'publish', |
| 288 |
'post_type' => 'page' |
| 289 |
); |
| 290 |
$register_id = wp_insert_post($register_page); |
| 291 |
|
| 292 |
$edit_page = array( |
| 293 |
'post_title' => 'Edit Profile', |
| 294 |
'post_content' => '[wppb-edit-profile]', |
| 295 |
'post_status' => 'publish', |
| 296 |
'post_type' => 'page' |
| 297 |
); |
| 298 |
$edit_id = wp_insert_post($edit_page); |
| 299 |
|
| 300 |
$login_page = array( |
| 301 |
'post_title' => 'Log In', |
| 302 |
'post_content' => '[wppb-login]', |
| 303 |
'post_status' => 'publish', |
| 304 |
'post_type' => 'page' |
| 305 |
); |
| 306 |
$login_id = wp_insert_post($login_page); |
| 307 |
|
| 308 |
update_option('wppb_pages_created', 'true' ); |
| 309 |
|
| 310 |
wp_safe_redirect( admin_url('edit.php?s=%5Bwppb-&post_status=all&post_type=page&action=-1&m=0&paged=1&action2=-1') ); |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
/** |
| 315 |
* Function that prepares labels to pass to the WCK api...we have a quirk in wck api that labels are wrapped |
| 316 |
* in %label%...so if we want to have % inside the label for example 25% off...we will have a bad time |
| 317 |
* @param string $label |
| 318 |
* @return string|string[] |
| 319 |
*/ |
| 320 |
function wppb_prepare_wck_labels( $label ){ |
| 321 |
return trim( str_replace( '%', '%', $label ) ); |
| 322 |
} |
| 323 |
|
| 324 |
/** |
| 325 |
* Function that returns the reserved meta name list |
| 326 |
*/ |
| 327 |
function wppb_get_reserved_meta_name_list( $all_fields, $posted_values ){ |
| 328 |
|
| 329 |
$unique_meta_name_list = array( 'first_name', 'last_name', 'nickname', 'description', 'role' ); |
| 330 |
|
| 331 |
// Default contact methods were removed in WP 3.6. A filter dictates contact methods. |
| 332 |
if ( apply_filters( 'wppb_remove_default_contact_methods', get_site_option( 'initial_db_version' ) < 23588 ) ){ |
| 333 |
$unique_meta_name_list[] = 'aim'; |
| 334 |
$unique_meta_name_list[] = 'yim'; |
| 335 |
$unique_meta_name_list[] = 'jabber'; |
| 336 |
} |
| 337 |
|
| 338 |
$add_reserved = true; |
| 339 |
|
| 340 |
// source: https://codex.wordpress.org/Reserved_Terms |
| 341 |
$reserved_meta_names = array( 'action', 'attachment', 'attachment_id', 'author', 'author_name', 'calendar', 'cat', 'category', 'category__and', 'category__in', 'category__not_in', 'category_name', 'comments_per_page', |
| 342 |
'comments_popup', 'custom', 'customize_messenger_channel', 'customized', 'cpage', 'day', 'debug', 'embed', 'error', 'exact', 'feed', 'fields', 'hour', 'link_category', 'm', 'map', 'minute', 'monthnum', 'more', |
| 343 |
'name', 'nav_menu', 'nonce', 'nopaging', 'offset', 'order', 'orderby', 'p', 'page', 'page_id', 'paged', 'pagename', 'pb', 'perm', 'post', 'post__in', 'post__not_in', 'post_format', 'post_mime_type', |
| 344 |
'post_status', 'post_tag', 'post_type', 'posts', 'posts_per_archive_page', 'posts_per_page', 'preview', 'robots', 's', 'search', 'second', 'sentence', 'showposts', 'static', 'status', 'subpost', |
| 345 |
'subpost_id', 'tag', 'tag__and', 'tag__in', 'tag__not_in', 'tag_id', 'tag_slug__and', 'tag_slug__in', 'taxonomy', 'tb', 'term', 'terms', 'theme', 'title', 'type', 'types', 'w', 'withcomments', 'withoutcomments', 'year' ); |
| 346 |
|
| 347 |
$args = array( |
| 348 |
'public' => true, |
| 349 |
'_builtin' => true |
| 350 |
); |
| 351 |
$post_types = get_post_types( $args, 'names', 'or' ); |
| 352 |
$taxonomies = get_taxonomies( $args, 'names', 'or' ); |
| 353 |
|
| 354 |
|
| 355 |
/*reserved meta names were added in PB 3.1.2 so to avoid the situation where someone updates an already existing field |
| 356 |
with a reserved name and gets an error check if it is an update or new field */ |
| 357 |
if( !empty( $all_fields ) && !empty($posted_values['id'] ) && !empty($posted_values['meta-name']) ){ |
| 358 |
foreach( $all_fields as $field ){ |
| 359 |
if( $field['id'] === $posted_values['id'] && $field['meta-name'] === $posted_values['meta-name'] ){//it is an update |
| 360 |
$add_reserved = false; |
| 361 |
} |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
if( $add_reserved ) |
| 366 |
$unique_meta_name_list = array_merge( $unique_meta_name_list, $reserved_meta_names, $post_types, $taxonomies ); |
| 367 |
|
| 368 |
return apply_filters ( 'wppb_unique_meta_name_list', $unique_meta_name_list ); |
| 369 |
} |
| 370 |
|
| 371 |
add_action('admin_head', 'wppb_maybe_remove_add_new_button_for_cpt' ); |
| 372 |
function wppb_maybe_remove_add_new_button_for_cpt() { |
| 373 |
|
| 374 |
global $pagenow; |
| 375 |
|
| 376 |
$target_slugs = [ 'wppb-rf-cpt', 'wppb-epf-cpt', 'wppb-ul-cpt' ]; |
| 377 |
$current_slug = ''; |
| 378 |
$pointer_content = ''; |
| 379 |
|
| 380 |
$correct_page = false; |
| 381 |
|
| 382 |
if ( $pagenow === 'edit.php' && isset( $_GET['post_type'] ) && in_array( sanitize_text_field( $_GET['post_type'] ), $target_slugs ) ) { |
| 383 |
$correct_page = true; |
| 384 |
$current_slug = sanitize_text_field( $_GET['post_type'] ); |
| 385 |
} else if( $pagenow === 'post.php' && isset( $_GET['post'] ) ) { |
| 386 |
|
| 387 |
$post_type = get_post_type( absint( $_GET['post'] ) ); |
| 388 |
|
| 389 |
if ( in_array( $post_type, $target_slugs ) ) { |
| 390 |
$correct_page = true; |
| 391 |
$current_slug = $post_type; |
| 392 |
} |
| 393 |
|
| 394 |
} |
| 395 |
|
| 396 |
if ( $correct_page ) { |
| 397 |
$license_status = wppb_get_serial_number_status(); |
| 398 |
|
| 399 |
if( $current_slug === 'wppb-rf-cpt' ) { |
| 400 |
if( $license_status == 'missing' ) { |
| 401 |
$pointer_content .= '<p>' . sprintf( __( 'Please %1$senter your license key%2$s first, to add new User Registration Forms.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-general-settings' ) .'">', '</a>' ) . '</p>'; |
| 402 |
} else { |
| 403 |
$pointer_content .= '<p>' . sprintf( __( 'You need an active license to add new User Registration Forms. %1$sRenew%2$s or %3$spurchase a new one%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=pb-registration-forms&utm_medium=client-site&utm_campaign=pb-expired-license">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-registration-forms&utm_medium=client-site&utm_campaign=pb-multi-registration-addon#pricing" target="_blank">', '</a>' ) . '</p>'; |
| 404 |
} |
| 405 |
} else if( $current_slug === 'wppb-epf-cpt' ) { |
| 406 |
if( $license_status == 'missing' ) { |
| 407 |
$pointer_content .= '<p>' . sprintf( __( 'Please %1$senter your license key%2$s first, to add new Edit Profile Forms.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-general-settings' ) .'">', '</a>' ) . '</p>'; |
| 408 |
} else { |
| 409 |
$pointer_content .= '<p>' . sprintf( __( 'You need an active license to add new Edit Profile Forms. %1$sRenew%2$s or %3$spurchase a new one%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=pb-edit-profile-forms&utm_medium=client-site&utm_campaign=pb-expired-license">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-edit-profile-forms&utm_medium=client-site&utm_campaign=pb-multi-edit-profile-addon#pricing" target="_blank">', '</a>' ) . '</p>'; |
| 410 |
} |
| 411 |
} else if( $current_slug === 'wppb-ul-cpt' ) { |
| 412 |
if( $license_status == 'missing' ) { |
| 413 |
$pointer_content .= '<p>' . sprintf( __( 'Please %1$senter your license key%2$s first, to add new User Listing.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-general-settings' ) .'">', '</a>' ) . '</p>'; |
| 414 |
} else { |
| 415 |
$pointer_content .= '<p>' . sprintf( __( 'You need an active license to add a new User Listing. %1$sRenew%2$s or %3$spurchase a new one%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=pb-user-listing&utm_medium=client-site&utm_campaign=pb-expired-license">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-user-listing&utm_medium=client-site&utm_campaign=pb-user-listing-addon#pricing" target="_blank">', '</a>' ) . '</p>'; |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
if( $license_status !== 'valid' ) { |
| 420 |
wp_enqueue_style('wp-pointer'); |
| 421 |
wp_enqueue_script('wp-pointer'); |
| 422 |
|
| 423 |
echo ' |
| 424 |
<script> |
| 425 |
jQuery(document).ready(function($) { |
| 426 |
let button_text = $(".page-title-action").text(); |
| 427 |
$(".page-title-action").remove(); |
| 428 |
|
| 429 |
$(".wrap .wp-heading-inline").after(`<a class="page-title-action page-title-action-disabled" style="cursor:pointer;">${button_text}</a>`); |
| 430 |
|
| 431 |
$(".page-title-action-disabled").on("click", function(e) { |
| 432 |
e.preventDefault(); |
| 433 |
|
| 434 |
let pointer_content = '. json_encode( $pointer_content ) .'; |
| 435 |
|
| 436 |
jQuery( this ).pointer({ |
| 437 |
content: pointer_content, |
| 438 |
position: { edge: "right", align: "middle" } |
| 439 |
}).pointer("open"); |
| 440 |
}); |
| 441 |
}); |
| 442 |
</script>'; |
| 443 |
} |
| 444 |
|
| 445 |
} |
| 446 |
|
| 447 |
// This shows the Add new button. Since the above action removes it completelty, we can just attempt to show it here |
| 448 |
echo '<script> |
| 449 |
jQuery(document).ready(function($) { |
| 450 |
if( $(".page-title-action").length > 0 ) { |
| 451 |
$(".page-title-action").css("display", "inline-flex"); |
| 452 |
} |
| 453 |
}); |
| 454 |
</script>'; |
| 455 |
|
| 456 |
// Manage fields |
| 457 |
if( isset( $_GET['page'] ) && $_GET['page'] === 'manage-fields' ) { |
| 458 |
$license_status = wppb_get_serial_number_status(); |
| 459 |
$pointer_content_cl = ''; |
| 460 |
$pointer_content_fv = ''; |
| 461 |
$pointer_content_epaa = ''; |
| 462 |
|
| 463 |
if( $license_status == 'missing' ) { |
| 464 |
$pointer_content_cl .= '<p>' . sprintf( __( 'Please %1$senter your license key%2$s first, to use the Conditional Logic feature.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-general-settings' ) .'">', '</a>' ) . '</p>'; |
| 465 |
$pointer_content_fv .= '<p>' . sprintf( __( 'Please %1$senter your license key%2$s first, to configure Field Visibility options.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-general-settings' ) .'">', '</a>' ) . '</p>'; |
| 466 |
$pointer_content_epaa .= '<p>' . sprintf( __( 'Please %1$senter your license key%2$s first, to use the Edit Profile Updates Approved by Admin addon feature.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-general-settings' ) .'">', '</a>' ) . '</p>'; |
| 467 |
} else { |
| 468 |
$pointer_content_cl .= '<p>' . sprintf( __( 'You need an active license to configure the Condi tional Logic feature. %1$sRenew%2$s or %3$spurchase a new one%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=pb-form-fields-conditional&utm_medium=client-site&utm_campaign=pb-expired-license">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-form-fields-conditional&utm_medium=client-site&utm_campaign=pb-conditional-logic#pricing" target="_blank">', '</a>' ) . '</p>'; |
| 469 |
$pointer_content_fv .= '<p>' . sprintf( __( 'You need an active license to configure Field Visibility options. %1$sRenew%2$s or %3$spurchase a new one%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=pb-form-fields-visibility&utm_medium=client-site&utm_campaign=pb-expired-license">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-form-fields-visibility&utm_medium=client-site&utm_campaign=pb-field-visibility#pricing" target="_blank">', '</a>' ) . '</p>'; |
| 470 |
$pointer_content_epaa .= '<p>' . sprintf( __( 'You need an active license to use the Edit Profile Updates Approved by Admin addon. %1$sRenew%2$s or %3$spurchase a new one%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=pb-form-fields-approval-on-edit-profile&utm_medium=client-site&utm_campaign=pb-expired-license">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-form-fields-approval-on-edit-profile&utm_medium=client-site&utm_campaign=pb-approval-on-edit-profile#pricing" target="_blank">', '</a>' ) . '</p>'; |
| 471 |
} |
| 472 |
|
| 473 |
if( $license_status != 'valid' ) { |
| 474 |
wp_enqueue_style('wp-pointer'); |
| 475 |
wp_enqueue_script('wp-pointer'); |
| 476 |
|
| 477 |
echo ' |
| 478 |
<script> |
| 479 |
jQuery(document).ready(function($) { |
| 480 |
|
| 481 |
$(document).on( "wpbFormMetaLoaded", function(e, meta) { |
| 482 |
|
| 483 |
wppb_manage_fields_license_invalid( e ); |
| 484 |
|
| 485 |
}); |
| 486 |
|
| 487 |
wppb_manage_fields_license_invalid(); |
| 488 |
|
| 489 |
function wppb_manage_fields_license_invalid(){ |
| 490 |
|
| 491 |
if( $(".row-conditional-logic-enabled").length > 0 ) { |
| 492 |
|
| 493 |
$(".row-conditional-logic").hide(); |
| 494 |
|
| 495 |
$("#edit_form_conditional-logic-enabled_yes, label[for=conditional-logic-enabled_yes]").on("click", function(e) { |
| 496 |
e.preventDefault(); |
| 497 |
e.stopPropagation(); |
| 498 |
e.stopImmediatePropagation(); |
| 499 |
|
| 500 |
let pointer_content = '. json_encode( $pointer_content_cl ) .'; |
| 501 |
let pointer_target = jQuery( this ).parent( ".cozmoslabs-toggle-container" ); |
| 502 |
|
| 503 |
if( e && e.currentTarget && jQuery( e.currentTarget ).hasClass( "cozmoslabs-form-field-label" ) ) { |
| 504 |
pointer_target = jQuery( this ); |
| 505 |
} |
| 506 |
|
| 507 |
pointer_target.pointer({ |
| 508 |
content: pointer_content, |
| 509 |
position: { edge: "right", align: "middle" } |
| 510 |
}).pointer("open"); |
| 511 |
}); |
| 512 |
} |
| 513 |
|
| 514 |
if( $(".row-edit-profile-approved-by-admin").length > 0 ) { |
| 515 |
|
| 516 |
$("#edit_form_edit-profile-approved-by-admin_yes, label[for=edit-profile-approved-by-admin_yes]").on("click", function(e) { |
| 517 |
e.preventDefault(); |
| 518 |
e.stopPropagation(); |
| 519 |
e.stopImmediatePropagation(); |
| 520 |
|
| 521 |
let pointer_content = '. json_encode( $pointer_content_epaa ) .'; |
| 522 |
let pointer_target = jQuery( this ).parent( ".cozmoslabs-toggle-container" ); |
| 523 |
|
| 524 |
if( e && e.currentTarget && jQuery( e.currentTarget ).hasClass( "cozmoslabs-form-field-label" ) ) { |
| 525 |
pointer_target = jQuery( this ); |
| 526 |
} |
| 527 |
|
| 528 |
pointer_target.pointer({ |
| 529 |
content: pointer_content, |
| 530 |
position: { edge: "right", align: "middle" } |
| 531 |
}).pointer("open"); |
| 532 |
}); |
| 533 |
} |
| 534 |
|
| 535 |
if( $(".row-visibility").length > 0 ) { |
| 536 |
|
| 537 |
$("select#visibility").on("mousedown", function(e) { |
| 538 |
e.preventDefault(); |
| 539 |
e.stopPropagation(); |
| 540 |
e.stopImmediatePropagation(); |
| 541 |
|
| 542 |
let pointer_content = '. json_encode( $pointer_content_fv ) .'; |
| 543 |
|
| 544 |
jQuery( this ).pointer({ |
| 545 |
content: pointer_content, |
| 546 |
position: { edge: "right", align: "middle" } |
| 547 |
}).pointer("open"); |
| 548 |
}); |
| 549 |
|
| 550 |
} |
| 551 |
|
| 552 |
if( $(".row-user-role-visibility").length > 0 ) { |
| 553 |
|
| 554 |
$(".row-user-role-visibility .wck-checkboxes input").attr("disabled", true).css("pointer-events", "none"); |
| 555 |
|
| 556 |
$(".row-user-role-visibility .wck-checkboxes").on("click", function(e) { |
| 557 |
e.preventDefault(); |
| 558 |
e.stopPropagation(); |
| 559 |
e.stopImmediatePropagation(); |
| 560 |
|
| 561 |
let pointer_content = '. json_encode( $pointer_content_fv ) .'; |
| 562 |
|
| 563 |
jQuery( this ).pointer({ |
| 564 |
content: pointer_content, |
| 565 |
position: { edge: "right", align: "middle" } |
| 566 |
}).pointer("open"); |
| 567 |
}); |
| 568 |
|
| 569 |
} |
| 570 |
|
| 571 |
if( $(".row-location-visibility").length > 0 ) { |
| 572 |
|
| 573 |
$(".row-location-visibility .wck-checkboxes input").attr("disabled", true).css("pointer-events", "none"); |
| 574 |
|
| 575 |
$(".row-location-visibility .wck-checkboxes").on("click", function(e) { |
| 576 |
e.preventDefault(); |
| 577 |
e.stopPropagation(); |
| 578 |
e.stopImmediatePropagation(); |
| 579 |
|
| 580 |
let pointer_content = '. json_encode( $pointer_content_fv ) .'; |
| 581 |
|
| 582 |
jQuery( this ).pointer({ |
| 583 |
content: pointer_content, |
| 584 |
position: { edge: "right", align: "middle" } |
| 585 |
}).pointer("open"); |
| 586 |
}); |
| 587 |
|
| 588 |
} |
| 589 |
|
| 590 |
} |
| 591 |
|
| 592 |
}); |
| 593 |
</script>'; |
| 594 |
} |
| 595 |
} |
| 596 |
|
| 597 |
} |
| 598 |
|
| 599 |
function wppb_filter_own_post_creation( $data, $postarr ) { |
| 600 |
if ( in_array( $data['post_type'], [ 'wppb-rf-cpt', 'wppb-epf-cpt', 'wppb-ul-cpt' ] ) && empty( $postarr['ID'] ) ) { |
| 601 |
|
| 602 |
$license_status = wppb_get_serial_number_status(); |
| 603 |
|
| 604 |
if( $license_status != 'valid' ) { |
| 605 |
wp_die( 'An active Profile Builder license is required to create new posts of this type.' ); |
| 606 |
} |
| 607 |
|
| 608 |
} |
| 609 |
|
| 610 |
return $data; |
| 611 |
} |
| 612 |
add_filter( 'wp_insert_post_data', 'wppb_filter_own_post_creation', 10, 2 ); |
| 613 |
|
| 614 |
add_filter( 'wck_update_meta_filter_values_wppb_manage_fields', 'wppb_filter_extra_manage_fields_options', 10, 2 ); |
| 615 |
function wppb_filter_extra_manage_fields_options( $values, $element_id ) { |
| 616 |
|
| 617 |
$license_status = wppb_get_serial_number_status(); |
| 618 |
|
| 619 |
if( $license_status == 'valid' ) |
| 620 |
return $values; |
| 621 |
|
| 622 |
if( !empty( $values['id'] ) ) { |
| 623 |
$manage_fields = get_option( 'wppb_manage_fields', array() ); |
| 624 |
$existing_field = false; |
| 625 |
|
| 626 |
if( !empty( $manage_fields ) ) { |
| 627 |
foreach( $manage_fields as $field ) { |
| 628 |
if( $field['id'] == $values['id'] ) { |
| 629 |
$existing_field = $field; |
| 630 |
break; |
| 631 |
} |
| 632 |
} |
| 633 |
} |
| 634 |
|
| 635 |
if( !empty( $existing_field ) ) { |
| 636 |
|
| 637 |
$target_keys = [ |
| 638 |
'visibility', |
| 639 |
'location-visibility', |
| 640 |
'user-role-visibility', |
| 641 |
'conditional-logic-enabled', |
| 642 |
'edit-profile-approved-by-admin', |
| 643 |
]; |
| 644 |
|
| 645 |
foreach( $target_keys as $key ) { |
| 646 |
if( !empty( $existing_field[$key] ) ) { |
| 647 |
$values[$key] = $existing_field[$key]; |
| 648 |
} |
| 649 |
} |
| 650 |
|
| 651 |
} |
| 652 |
|
| 653 |
} |
| 654 |
|
| 655 |
return $values; |
| 656 |
|
| 657 |
} |
| 658 |
/** |
| 659 |
* Function that adds an admin notification about the PB Form Design Styles |
| 660 |
* |
| 661 |
*/ |
| 662 |
// function wppb_form_design_new_styles_notification() { |
| 663 |
|
| 664 |
// if( current_user_can( 'manage_options' ) ) |
| 665 |
// return; |
| 666 |
|
| 667 |
// /* initiate the plugin notifications class */ |
| 668 |
// $notifications = WPPB_Plugin_Notifications::get_instance(); |
| 669 |
// /* this must be unique */ |
| 670 |
// $notification_id = 'wppb_form_design_new_styles'; |
| 671 |
|
| 672 |
// if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR.'/features/form-designs/form-designs.php' ) ) |
| 673 |
// $notification_message = '<p style="font-size: 15px; margin-top:4px;">' . sprintf( __( 'You can now beautify your Forms using new %1$sForm Styles%2$s by selecting and activating the one you like in %3$sProfile Builder -> Settings%4$s.', 'profile-builder' ), '<strong>', '</strong>', '<a href="'. get_site_url() .'/wp-admin/admin.php?page=profile-builder-general-settings#wppb-form_desings">', '</a>') . '</p>'; |
| 674 |
// else |
| 675 |
// $notification_message = '<p style="font-size: 15px; margin-top:4px;">' . sprintf( __( 'You can now beautify your Forms using %1$sForm Styles%2$s. Have a look at the new Styles in %3$sProfile Builder -> Settings%4$s.', 'profile-builder' ), '<strong>', '</strong>', '<a href="'. get_site_url() .'/wp-admin/admin.php?page=profile-builder-general-settings#wppb-form_desings">', '</a>') . '</p>'; |
| 676 |
|
| 677 |
// $ul_icon_url = ( file_exists( WPPB_PLUGIN_DIR . 'assets/images/pb-logo.svg' )) ? WPPB_PLUGIN_URL . 'assets/images/pb-logo.svg' : ''; |
| 678 |
// $ul_icon = ( !empty($ul_icon_url)) ? '<img src="'. $ul_icon_url .'" width="64" height="64" style="float: left; margin: 15px 12px 15px 0; max-width: 100px;" alt="Profile Builder - Form Designs">' : ''; |
| 679 |
|
| 680 |
// $message = $ul_icon; |
| 681 |
// $message .= '<h3 style="margin-bottom: 0;">Profile Builder PRO - Form Designs</h3>'; |
| 682 |
// $message .= $notification_message; |
| 683 |
// $message .= '<a href="' . wp_nonce_url( add_query_arg( array( 'wppb_dismiss_admin_notification' => $notification_id ) ), 'wppb_plugin_notice_dismiss' ) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'profile-builder' ) . '</span></a>'; |
| 684 |
|
| 685 |
// $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info', false ); |
| 686 |
// } |
| 687 |
// add_action( 'admin_init', 'wppb_form_design_new_styles_notification' ); |
| 688 |
|
| 689 |
function wppb_in_ffc_admin_notification() { |
| 690 |
|
| 691 |
if( !current_user_can( 'manage_options' ) ) |
| 692 |
return; |
| 693 |
|
| 694 |
/* initiate the plugin notifications class */ |
| 695 |
$notifications = WPPB_Plugin_Notifications::get_instance(); |
| 696 |
/* this must be unique */ |
| 697 |
$notification_id = 'wppb_ffc_notification'; |
| 698 |
|
| 699 |
$notification_message = '<p style="font-size: 15px; margin-top:4px;">' . sprintf( __( 'New add-on released: %1$sForm Fields in Columns%2$s.<br>Place multiple fields on the same row to create better looking forms for your users.', 'profile-builder' ), '<strong>', '</strong>') . '</p>'; |
| 700 |
$extra_message = sprintf( __( 'Go to the %1$sProfile Builder -> Add-ons%2$s page to activate the add-on.', 'profile-builder' ), '<a href="'. admin_url( 'admin.php?page=profile-builder-add-ons' ) . '">', '</a>'); |
| 701 |
|
| 702 |
if( !defined( 'WPPB_PAID_PLUGIN_DIR' ) ) |
| 703 |
$extra_message .= sprintf( __( ' Don\'t have a license? %sBuy one now%s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=ffc_notification&utm_campaign=PBFree#pricing" target="_blank">', '</a>'); |
| 704 |
|
| 705 |
$notification_message .= '<p style="font-size: 15px; margin-top:4px; padding-left: 77px;">' . $extra_message . '</p>'; |
| 706 |
|
| 707 |
$ul_icon_url = ( file_exists( WPPB_PLUGIN_DIR . 'assets/images/add-ons/pb-add-on-form-fields-in-columns-logo.png' )) ? WPPB_PLUGIN_URL . 'assets/images/add-ons/pb-add-on-form-fields-in-columns-logo.png' : ''; |
| 708 |
$ul_icon = ( !empty( $ul_icon_url ) ) ? '<img src="'. $ul_icon_url .'" width="64" height="64" style="float: left; margin: 15px 12px 15px 0; max-width: 100px;" alt="Profile Builder - Form Fields in Columns">' : ''; |
| 709 |
|
| 710 |
$message = $ul_icon; |
| 711 |
$message .= '<h3 style="margin-bottom: 0;">Profile Builder - New Add-on</h3>'; |
| 712 |
$message .= $notification_message; |
| 713 |
$message .= '<a href="' . wp_nonce_url( add_query_arg( array( 'wppb_dismiss_admin_notification' => $notification_id ) ), 'wppb_plugin_notice_dismiss' ) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'profile-builder' ) . '</span></a>'; |
| 714 |
|
| 715 |
$notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info', false ); |
| 716 |
|
| 717 |
} |
| 718 |
add_action( 'admin_init', 'wppb_in_ffc_admin_notification' ); |
| 719 |
|
| 720 |
/** |
| 721 |
* Get the Profile Builder Page or Post slug |
| 722 |
* |
| 723 |
*/ |
| 724 |
function wppb_get_pb_page_post_slug() { |
| 725 |
if ( isset( $_GET['post_type'] ) ) |
| 726 |
$post_type = sanitize_text_field( $_GET['post_type'] ); |
| 727 |
elseif ( isset( $_GET['post'] ) ) |
| 728 |
$post_type = get_post_type( (int)$_GET['post'] ); |
| 729 |
elseif ( isset( $_GET['page'] ) ) |
| 730 |
$post_type = sanitize_text_field( $_GET['page'] ); |
| 731 |
else $post_type = ''; |
| 732 |
|
| 733 |
$possible_slugs = array( |
| 734 |
'pb', |
| 735 |
'wppb', |
| 736 |
'profile-builder', |
| 737 |
'user-email-customizer', |
| 738 |
'admin-email-customizer', |
| 739 |
'manage-fields', |
| 740 |
'custom-redirects', |
| 741 |
'profile-user-profile-picture' |
| 742 |
); |
| 743 |
|
| 744 |
if ( !empty( $post_type ) ) { |
| 745 |
foreach ( $possible_slugs as $slug ) { |
| 746 |
if ( ($post_type === $slug || strpos( $post_type, $slug ) === 0) && strpos($post_type, 'pb_backupbuddy') === false ) { |
| 747 |
|
| 748 |
return $post_type; |
| 749 |
|
| 750 |
} |
| 751 |
} |
| 752 |
} |
| 753 |
|
| 754 |
return ''; |
| 755 |
} |
| 756 |
|
| 757 |
|
| 758 |
/** |
| 759 |
* Insert the PB Admin area Header Banner |
| 760 |
* |
| 761 |
*/ |
| 762 |
function wppb_insert_page_banner() { |
| 763 |
$pb_slug = wppb_get_pb_page_post_slug(); |
| 764 |
|
| 765 |
if ( $pb_slug === 'profile-builder-dashboard' && isset( $_GET['subpage'] ) && $_GET['subpage'] === 'wppb-setup' ) |
| 766 |
return; |
| 767 |
|
| 768 |
$page_name = ''; |
| 769 |
if ( $pb_slug == 'profile-builder-add-ons' ) |
| 770 |
$page_name = ' Add-Ons'; |
| 771 |
|
| 772 |
if ( !empty( $pb_slug ) ) |
| 773 |
wppb_output_page_banner($page_name); |
| 774 |
|
| 775 |
} |
| 776 |
add_action( 'in_admin_header', 'wppb_insert_page_banner' ); |
| 777 |
|
| 778 |
|
| 779 |
/** |
| 780 |
* Output the PB Admin area Header Banner content |
| 781 |
* |
| 782 |
*/ |
| 783 |
function wppb_output_page_banner( $page_name ) { |
| 784 |
|
| 785 |
$upgrade_button = '<a class="cozmoslabs-banner-link cozmoslabs-upgrade-link" href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-settings&utm_medium=client-site&utm_campaign=pb-header-upsell#pricing" target="_blank"> |
| 786 |
<img src="'. esc_url(WPPB_PLUGIN_URL) . 'assets/images/upgrade-link-icon.svg" alt=""> |
| 787 |
Upgrade to PRO |
| 788 |
</a>'; |
| 789 |
|
| 790 |
$upgrade_button_basic = '<a class="cozmoslabs-banner-link cozmoslabs-upgrade-link" href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-settings&utm_medium=client-site&utm_campaign=pb-header-upsell#pricing" target="_blank"> |
| 791 |
<img src="'. esc_url(WPPB_PLUGIN_URL) . 'assets/images/upgrade-link-icon.svg" alt=""> |
| 792 |
Upgrade to PRO |
| 793 |
</a>'; |
| 794 |
|
| 795 |
$support_url = 'https://www.cozmoslabs.com/support/?utm_source=pb-settings&utm_medium=client-site&utm_campaign=pb-header-upsell'; |
| 796 |
|
| 797 |
if ( !defined( 'WPPB_PAID_PLUGIN_DIR' ) ) |
| 798 |
$support_url = 'https://wordpress.org/support/plugin/profile-builder/'; |
| 799 |
|
| 800 |
$output = '<div class="cozmoslabs-banner"> |
| 801 |
<div class="cozmoslabs-banner-title"> |
| 802 |
<img src="'. esc_url(WPPB_PLUGIN_URL) . 'assets/images/pb-logo.svg" alt=""> |
| 803 |
<h4>Profile Builder'. $page_name .'</h4> |
| 804 |
</div> |
| 805 |
<div class="cozmoslabs-banner-buttons"> |
| 806 |
<a class="cozmoslabs-banner-link cozmoslabs-support-link" href="'. $support_url .'" target="_blank"> |
| 807 |
<img src="'. esc_url(WPPB_PLUGIN_URL) . 'assets/images/support-link-icon.svg" alt=""> |
| 808 |
Support |
| 809 |
</a> |
| 810 |
|
| 811 |
<a class="cozmoslabs-banner-link cozmoslabs-documentation-link" href="https://www.cozmoslabs.com/docs/profile-builder/?utm_source=pb-settings&utm_medium=client-site&utm_campaign=pb-header-upsell" target="_blank"> |
| 812 |
<img src="'. esc_url(WPPB_PLUGIN_URL) . 'assets/images/docs-link-icon.svg" alt=""> |
| 813 |
Documentation |
| 814 |
</a>'; |
| 815 |
|
| 816 |
if ( !defined( 'WPPB_PAID_PLUGIN_DIR' ) || ( defined( 'PROFILE_BUILDER_PAID_VERSION' ) && PROFILE_BUILDER_PAID_VERSION === 'dev' ) ) |
| 817 |
$output .= $upgrade_button; |
| 818 |
|
| 819 |
// Add Basic version upgrade button (not to account, to plugin purchase page) |
| 820 |
if( defined( 'PROFILE_BUILDER' ) && PROFILE_BUILDER == 'Profile Builder Basic' ){ |
| 821 |
$output .= $upgrade_button_basic; |
| 822 |
} |
| 823 |
|
| 824 |
$output .= ' </div> |
| 825 |
</div>'; |
| 826 |
|
| 827 |
echo $output; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 828 |
} |
| 829 |
|
| 830 |
|
| 831 |
/** |
| 832 |
* Remove PMS Styles from PB Pages and Posts |
| 833 |
* |
| 834 |
*/ |
| 835 |
function wppb_maybe_remove_pms_styles() { |
| 836 |
if ( !empty( wppb_get_pb_page_post_slug() ) && wp_style_is('pms-style-back-end', 'enqueued') ) { |
| 837 |
wp_dequeue_style('pms-style-back-end'); |
| 838 |
} |
| 839 |
} |
| 840 |
add_action('admin_enqueue_scripts', 'wppb_maybe_remove_pms_styles', 100); |