| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Register Global Fields |
| 5 |
* |
| 6 |
* @package NotificationX\Extensions |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace NotificationX\Core; |
| 10 |
|
| 11 |
use NotificationX\Admin\Admin; |
| 12 |
use NotificationX\Core\Rules; |
| 13 |
use NotificationX\Core\Database; |
| 14 |
use NotificationX\Core\Locations; |
| 15 |
use NotificationX\GetInstance; |
| 16 |
use NotificationX\Core\Modules; |
| 17 |
use NotificationX\Extensions\GlobalFields; |
| 18 |
use NotificationX\NotificationX; |
| 19 |
use NotificationX\Types\TypeFactory; |
| 20 |
|
| 21 |
/** |
| 22 |
* @method static QuickBuild get_instance($args = null) |
| 23 |
*/ |
| 24 |
class QuickBuild { |
| 25 |
/** |
| 26 |
* Instance of QuickBuild |
| 27 |
* |
| 28 |
* @var QuickBuild |
| 29 |
*/ |
| 30 |
use GetInstance; |
| 31 |
|
| 32 |
/** |
| 33 |
* Initially Invoked when initialized. |
| 34 |
*/ |
| 35 |
public function __construct() { |
| 36 |
add_action('admin_menu', [$this, 'menu'], 27); |
| 37 |
|
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* This method is responsible for Admin Menu of |
| 42 |
* NotificationX |
| 43 |
* |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
public function menu() { |
| 47 |
add_submenu_page('nx-admin', __('Quick Builder', 'notificationx'), __('Quick Builder', 'notificationx'), 'edit_notificationx', 'nx-builder', [Admin::get_instance(), 'views'], 5); |
| 48 |
} |
| 49 |
|
| 50 |
public function tabs($configs = []) { |
| 51 |
if(empty($configs)){ |
| 52 |
$configs = GlobalFields::get_instance()->tabs(); |
| 53 |
} |
| 54 |
|
| 55 |
$tabs = [ |
| 56 |
'source_tab' => $configs['tabs']['source_tab'], |
| 57 |
'design_tab' => $configs['tabs']['design_tab'], |
| 58 |
'content_tab' => [], |
| 59 |
'manager_tab' => $configs['tabs']['manager_tab'], |
| 60 |
'display_tab' => $configs['tabs']['display_tab'], |
| 61 |
'finalize' => [ |
| 62 |
'label' => "Finalize", |
| 63 |
'id' => "finalize", |
| 64 |
'icon' => [ |
| 65 |
'type' => 'tabs', |
| 66 |
'name' => 'source' |
| 67 |
], |
| 68 |
'classes' => "finalize", |
| 69 |
'fields' => [ |
| 70 |
'finalize_message' => [ |
| 71 |
'type' => 'action', |
| 72 |
'action' => 'nx_quick_build_finalize', |
| 73 |
], |
| 74 |
], |
| 75 |
|
| 76 |
], |
| 77 |
]; |
| 78 |
|
| 79 |
if(!empty($configs['tabs']['content_tab']['fields']['content']['fields']['custom_contents'])){ |
| 80 |
$tabs['content_tab'] = [ |
| 81 |
'label' => "Content", |
| 82 |
'id' => "content_tab", |
| 83 |
'name' => "content_tab", |
| 84 |
'icon' => [ |
| 85 |
'type' => 'tabs', |
| 86 |
'name' => 'content' |
| 87 |
], |
| 88 |
'classes' => "content_tab", |
| 89 |
'rules' => Rules::includes('source', ['custom_notification', 'custom_notification_conversions']), |
| 90 |
'fields' => [ |
| 91 |
'content' => [ |
| 92 |
'label' => __("Content", 'notificationx'), |
| 93 |
'name' => "content", |
| 94 |
'type' => "section", |
| 95 |
'priority' => 90, |
| 96 |
'fields' => [ |
| 97 |
'custom_contents' => $configs['tabs']['content_tab']['fields']['content']['fields']['custom_contents'], |
| 98 |
], |
| 99 |
], |
| 100 |
] |
| 101 |
]; |
| 102 |
|
| 103 |
unset($configs['tabs']['content_tab']['fields']['content']['fields']['custom_contents']); |
| 104 |
} |
| 105 |
else{ |
| 106 |
unset($tabs['content_tab']); |
| 107 |
} |
| 108 |
|
| 109 |
$tabs['source_tab']['fields'] = array_merge($tabs['source_tab']['fields'], $configs['tabs']['content_tab']['fields']); |
| 110 |
$tabs['display_tab']['fields'] = array_merge($tabs['display_tab']['fields'], $configs['tabs']['customize_tab']['fields']); |
| 111 |
|
| 112 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. |
| 113 |
return apply_filters('nx_quick_builder_tabs', [ |
| 114 |
'id' => 'notificationx_metabox_quick_builder_wrapper', |
| 115 |
'redirect' => !current_user_can( 'edit_notificationx' ), |
| 116 |
'title' => __('NotificationX', 'notificationx'), |
| 117 |
'is_pro_active' => NotificationX::get_instance()->is_pro(), |
| 118 |
'config' => [ |
| 119 |
'active' => "source_tab", |
| 120 |
'completionTrack' => true, |
| 121 |
'sidebar' => false, |
| 122 |
'step' => [ |
| 123 |
'show' => true, |
| 124 |
'buttons' => [ |
| 125 |
'prev' => 'Previous', |
| 126 |
'next' => 'Next', |
| 127 |
'quick-builder-publish' => [ |
| 128 |
'name' => 'quick-builder-publish', |
| 129 |
'type' => 'action', |
| 130 |
'action' => 'nx_quick_build_launch', |
| 131 |
], |
| 132 |
] |
| 133 |
], |
| 134 |
], |
| 135 |
'submit' => [ |
| 136 |
'show' => false, |
| 137 |
], |
| 138 |
'tabs' => $tabs, |
| 139 |
'quickBuilder' => true, |
| 140 |
'show' => [ |
| 141 |
'source_error', |
| 142 |
'finalize_message', |
| 143 |
'youtube_channel_id', |
| 144 |
'youtube_video_id', |
| 145 |
'type_section', |
| 146 |
'themes_section', |
| 147 |
'for_desktop', |
| 148 |
'for_mobile', |
| 149 |
'is_mobile_responsive', |
| 150 |
'responsive_themes', |
| 151 |
'desktop_themes', |
| 152 |
'type', |
| 153 |
'source_section', |
| 154 |
'source', |
| 155 |
'themes', |
| 156 |
'gdpr_theme', |
| 157 |
'gdpr_position', |
| 158 |
'gdpr_title', |
| 159 |
'gdpr_message', |
| 160 |
'cookies_list_section', |
| 161 |
'content', |
| 162 |
'combine_multiorder', |
| 163 |
'freemius_item_type', |
| 164 |
'freemius_themes', |
| 165 |
'freemius_plugins', |
| 166 |
'wp_reviews_product_type', |
| 167 |
'wp_reviews_slug', |
| 168 |
'wp_stats_product_type', |
| 169 |
'wp_stats_slug', |
| 170 |
'press_content', |
| 171 |
'form_list', |
| 172 |
'mailchimp_list', |
| 173 |
'convertkit_form', |
| 174 |
'custom_contents', |
| 175 |
'title', |
| 176 |
'post_title', |
| 177 |
'post_comment', |
| 178 |
'username', |
| 179 |
'name', |
| 180 |
'first_name', |
| 181 |
'last_name', |
| 182 |
'email', |
| 183 |
'city', |
| 184 |
'country', |
| 185 |
'sales_count', |
| 186 |
'donation_count', |
| 187 |
'image', |
| 188 |
'link', |
| 189 |
'rated', |
| 190 |
'plugin_name', |
| 191 |
'plugin_review', |
| 192 |
'rating', |
| 193 |
'today', |
| 194 |
'last_week', |
| 195 |
'all_time', |
| 196 |
'active_installs', |
| 197 |
'timestamp', |
| 198 |
'appearance', |
| 199 |
'position', |
| 200 |
'visibility', |
| 201 |
'show_on', |
| 202 |
'all_locations', |
| 203 |
'show_on_display', |
| 204 |
|
| 205 |
'google_reviews_place_data', |
| 206 |
'google_reviews_custom_place_id', |
| 207 |
|
| 208 |
'ft_theme_one_icons', |
| 209 |
'ft_theme_one_message', |
| 210 |
'ft_theme_three_line_one', |
| 211 |
'ft_theme_three_line_two', |
| 212 |
'ft_theme_four_line_two', |
| 213 |
'close_button', |
| 214 |
'close_button_tab', |
| 215 |
'close_button_mobile', |
| 216 |
'hide_on_desktop', |
| 217 |
'hide_on_tab', |
| 218 |
'hide_on_mobile', |
| 219 |
'notification-template', |
| 220 |
'first_param', |
| 221 |
'custom_first_param', |
| 222 |
'second_param', |
| 223 |
'third_param', |
| 224 |
'custom_third_param', |
| 225 |
'fourth_param', |
| 226 |
'custom_fourth_param', |
| 227 |
'fifth_param', |
| 228 |
'custom_fifth_param', |
| 229 |
'sixth_param', |
| 230 |
'custom_sixth_param', |
| 231 |
'activecampaign_form', |
| 232 |
'announcement_entries', |
| 233 |
'offer_title', |
| 234 |
'offer_discount', |
| 235 |
'image', |
| 236 |
'expire_time', |
| 237 |
'offer_description', |
| 238 |
'press_sliding_text', |
| 239 |
'sliding_text', |
| 240 |
'bar_content_type', |
| 241 |
'sliding_content', |
| 242 |
'countdown_timer', |
| 243 |
'enable_countdown', |
| 244 |
'evergreen_timer', |
| 245 |
'countdown_text', |
| 246 |
'countdown_expired_text', |
| 247 |
'countdown_start_date', |
| 248 |
'countdown_end_date', |
| 249 |
'time_randomize', |
| 250 |
'time_randomize_between', |
| 251 |
'time_rotation', |
| 252 |
'time_reset', |
| 253 |
'nxbar_build_with_ai', |
| 254 |
// Exit Intent Popup — Custom (Elementor) tab controls. The Quick |
| 255 |
// Builder hides any field name not listed here, so without these the |
| 256 |
// "Build With Elementor" button (and the rest of the Custom-tab flow) |
| 257 |
// never render in the Quick Builder. |
| 258 |
'exit_intent_custom_preview', |
| 259 |
'build_with_elementor', |
| 260 |
'nx-exit-intent_with_elementor', |
| 261 |
'nx-exit-intent_with_elementor-remove', |
| 262 |
'nx-exit-intent_with_elementor_install', |
| 263 |
'elementor_edit_link', |
| 264 |
'elementor_exit_theme', |
| 265 |
'import_elementor_theme', |
| 266 |
'import_elementor_theme_next', |
| 267 |
'exit_intent_ai_tab', |
| 268 |
'exit-intent-build_with_ai', |
| 269 |
], |
| 270 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. |
| 271 |
'types_title' => apply_filters( 'nx_source_types_title', array( |
| 272 |
'notification_bar' => __('Notification Bar', 'notificationx'), |
| 273 |
'comments' => __('Comments', 'notificationx'), |
| 274 |
'conversions' => __('Sales Notification', 'notificationx'), |
| 275 |
'video' => __('Video','notificationx'), |
| 276 |
'reviews' => __('Reviews', 'notificationx'), |
| 277 |
'download_stats' => __('Download Stats', 'notificationx'), |
| 278 |
'elearning' => __('eLearning', 'notificationx'), |
| 279 |
'donation' => __('Donation', 'notificationx'), |
| 280 |
'form' => __('Contact Form', 'notificationx'), |
| 281 |
'inline' => __('Growth Alert', 'notificationx'), |
| 282 |
'gdpr' => __('Cookie Notice', 'notificationx'), |
| 283 |
)), |
| 284 |
]); |
| 285 |
} |
| 286 |
|
| 287 |
} |
| 288 |
|
| 289 |
|