Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 348 |
|
0.00% |
0 / 15 |
CRAP | |
0.00% |
0 / 5 |
| zeroBSCRM_FormsMetaboxSetup | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| zeroBS__Metabox_FormLanguage | |
0.00% |
0 / 76 |
|
0.00% |
0 / 5 |
930 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |||
| html | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
132 | |||
| save_data | |
0.00% |
0 / 31 |
|
0.00% |
0 / 1 |
182 | |||
| post_save_data | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |||
| updateMessage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| zeroBS__Metabox_FormSettings | |
0.00% |
0 / 181 |
|
0.00% |
0 / 3 |
1056 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |||
| html | |
0.00% |
0 / 161 |
|
0.00% |
0 / 1 |
812 | |||
| save_data | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| zeroBS__Metabox_FormEmbed | |
0.00% |
0 / 28 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |||
| html | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
30 | |||
| zeroBS__Metabox_FormMoreFields | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |||
| html | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| zeroBS__Metabox_FormActions | |
0.00% |
0 / 35 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
2 | |||
| html | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | /* |
| 3 | * Jetpack CRM |
| 4 | * https://jetpackcrm.com |
| 5 | * V3.0 |
| 6 | * |
| 7 | * Copyright 2020 Automattic |
| 8 | * |
| 9 | * Date: 20/02/2019 |
| 10 | */ |
| 11 | |
| 12 | defined( 'ZEROBSCRM_PATH' ) || exit( 0 ); |
| 13 | |
| 14 | /* |
| 15 | ====================================================== |
| 16 | Init Func |
| 17 | ====================================================== */ |
| 18 | |
| 19 | function zeroBSCRM_FormsMetaboxSetup() { |
| 20 | |
| 21 | // form language labels |
| 22 | $zeroBS__Metabox_FormLanguage = new zeroBS__Metabox_FormLanguage( __FILE__ ); |
| 23 | |
| 24 | // form settings |
| 25 | $zeroBS__Metabox_FormSettings = new zeroBS__Metabox_FormSettings( __FILE__ ); |
| 26 | |
| 27 | // form embed info |
| 28 | $zeroBS__Metabox_FormEmbed = new zeroBS__Metabox_FormEmbed( __FILE__ ); |
| 29 | |
| 30 | ##WLREMOVE |
| 31 | // upsell more fields |
| 32 | if ( ! zeroBSCRM_hasPaidExtensionActivated() ) { |
| 33 | $zeroBS__Metabox_FormMoreFields = new zeroBS__Metabox_FormMoreFields( __FILE__ ); |
| 34 | } |
| 35 | ##/WLREMOVE |
| 36 | |
| 37 | // save |
| 38 | $zeroBS__Metabox_FormActions = new zeroBS__Metabox_FormActions( __FILE__ ); |
| 39 | } |
| 40 | |
| 41 | add_action( 'admin_init', 'zeroBSCRM_FormsMetaboxSetup' ); |
| 42 | |
| 43 | /* |
| 44 | ====================================================== |
| 45 | / Init Func |
| 46 | ====================================================== */ |
| 47 | |
| 48 | /* |
| 49 | ====================================================== |
| 50 | Forms v3 Language Metabox |
| 51 | ====================================================== */ |
| 52 | |
| 53 | class zeroBS__Metabox_FormLanguage extends zeroBS__Metabox { |
| 54 | |
| 55 | // this is for catching 'new' forms |
| 56 | private $newRecordNeedsRedir = false; |
| 57 | |
| 58 | // this is to save + edit $fieldPrefix = 'zbsf_'; |
| 59 | private $fieldPrefix = 'zbsf_'; |
| 60 | |
| 61 | public function __construct( $plugin_file ) { |
| 62 | |
| 63 | // set these |
| 64 | // DAL3 switched for objType $this->postType = 'zerobs_customer'; |
| 65 | $this->objType = 'form'; |
| 66 | $this->metaboxID = 'zerobs-form-edit'; |
| 67 | $this->metaboxTitle = __( 'Form Language Labels', 'zero-bs-crm' ); |
| 68 | $this->metaboxScreen = 'zbs-add-edit-form-edit'; |
| 69 | $this->metaboxArea = 'normal'; |
| 70 | $this->metaboxLocation = 'high'; |
| 71 | $this->saveOrder = 1; |
| 72 | $this->capabilities = array( |
| 73 | |
| 74 | 'can_hide' => false, // can be hidden |
| 75 | 'areas' => array( 'normal' ), // areas can be dragged to - normal side = only areas currently |
| 76 | 'can_accept_tabs' => true, // can/can't accept tabs onto it |
| 77 | 'can_become_tab' => false, // can be added as tab |
| 78 | 'can_minimise' => true, // can be minimised |
| 79 | 'can_move' => true, // can be moved |
| 80 | |
| 81 | ); |
| 82 | |
| 83 | // call this |
| 84 | $this->initMetabox(); |
| 85 | } |
| 86 | |
| 87 | public function html( $form, $metabox ) { |
| 88 | |
| 89 | // localise ID |
| 90 | $formID = -1; |
| 91 | if ( is_array( $form ) && isset( $form['id'] ) ) { |
| 92 | $formID = (int) $form['id']; |
| 93 | } |
| 94 | |
| 95 | // if new + $zbsObjDataPrefill passed, use that instead of loaded trans. |
| 96 | if ( $formID == -1 ) { |
| 97 | global $zbsObjDataPrefill; |
| 98 | $form = $zbsObjDataPrefill; |
| 99 | } |
| 100 | |
| 101 | // fields |
| 102 | global $zbsFormFields; |
| 103 | |
| 104 | ?> |
| 105 | |
| 106 | <script type="text/javascript">var zbscrmjs_secToken = '<?php echo esc_js( wp_create_nonce( 'zbscrmjs-ajax-nonce' ) ); ?>';</script> |
| 107 | |
| 108 | <table class="form-table wh-metatab wptbp"> |
| 109 | <?php |
| 110 | foreach ( $zbsFormFields as $fieldK => $fieldV ) { |
| 111 | |
| 112 | #} Ignore no and date, dealt with above |
| 113 | switch ( $fieldV[0] ) { |
| 114 | |
| 115 | case 'text': |
| 116 | ?> |
| 117 | <tr class="wh-large"><th><label for="<?php echo esc_attr( $fieldK ); ?>"><?php esc_html_e( $fieldV[1], 'zero-bs-crm' ); ?>:</label></th> |
| 118 | <td> |
| 119 | <input type="text" name="<?php echo esc_attr( $this->fieldPrefix . $fieldK ); ?>" id="<?php echo esc_attr( $fieldK ); ?>" class="form-control widetext" placeholder="<?php echo ! empty( $fieldV[2] ) ? esc_attr( __( $fieldV[2], 'zero-bs-crm' ) ) : ''; ?>" value="<?php echo ! empty( $form[ $fieldK ] ) ? esc_attr( $form[ $fieldK ] ) : ''; ?>" /> |
| 120 | </td></tr> |
| 121 | <?php |
| 122 | |
| 123 | break; |
| 124 | |
| 125 | case 'textarea': |
| 126 | ?> |
| 127 | <tr class="wh-large"><th><label for="<?php echo esc_attr( $fieldK ); ?>"><?php esc_html_e( $fieldV[1], 'zero-bs-crm' ); ?>:</label></th> |
| 128 | <td> |
| 129 | <textarea name="<?php echo esc_attr( $this->fieldPrefix . $fieldK ); ?>" id="<?php echo esc_attr( $fieldK ); ?>" class="form-control" placeholder="<?php echo ! empty( $fieldV[2] ) ? esc_attr( __( $fieldV[2], 'zero-bs-crm' ) ) : ''; ?>"><?php echo ! empty( $form[ $fieldK ] ) ? esc_textarea( $form[ $fieldK ] ) : ''; ?></textarea> |
| 130 | </td></tr> |
| 131 | <?php |
| 132 | |
| 133 | break; |
| 134 | |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | ?> |
| 139 | </table> |
| 140 | <div class="clear"></div> |
| 141 | <?php |
| 142 | } |
| 143 | |
| 144 | public function save_data( $form_id, $form ) { |
| 145 | |
| 146 | if ( ! defined( 'ZBS_OBJ_SAVED' ) ) { |
| 147 | |
| 148 | // debug if (get_current_user_id() == 12) echo 'FIRING<br>'; |
| 149 | |
| 150 | define( 'ZBS_OBJ_SAVED', 1 ); |
| 151 | |
| 152 | // DAL3.0+ |
| 153 | global $zbs; |
| 154 | |
| 155 | // check this |
| 156 | if ( empty( $form_id ) || $form_id < 1 ) { |
| 157 | $form_id = -1; |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | old way: |
| 162 | |
| 163 | global $zbsFormFields; |
| 164 | foreach ($zbsFormFields as $fK => $fV){ |
| 165 | $zbsFormFieldMeta[$fK] = ''; |
| 166 | if (isset($_POST['zbscf_'.$fK])) { |
| 167 | switch ($fV[0]){ |
| 168 | case 'text': |
| 169 | $zbsFormFieldMeta[$fK] = zeroBSCRM_textProcess($_POST['zbscf_'.$fK]); |
| 170 | break; |
| 171 | case 'textarea': |
| 172 | $zbsFormFieldMeta[$fK] = zeroBSCRM_textProcess($_POST['zbscf_'.$fK]); |
| 173 | break; |
| 174 | default: |
| 175 | $zbsFormFieldMeta[$fK] = sanitize_text_field($_POST['zbscf_'.$fK]); |
| 176 | break; |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | update_post_meta($post_id, 'zbs_form_field_meta', $zbsFormFieldMeta); |
| 181 | |
| 182 | */ |
| 183 | |
| 184 | // DAL3 way: |
| 185 | $autoGenAutonumbers = true; // generate if not set :) |
| 186 | $form = zeroBS_buildObjArr( $_POST, array(), $this->fieldPrefix, '', false, ZBS_TYPE_FORM, $autoGenAutonumbers ); |
| 187 | |
| 188 | // add/update |
| 189 | $addUpdateReturn = $zbs->DAL->forms->addUpdateForm( |
| 190 | array( |
| 191 | |
| 192 | 'id' => $form_id, |
| 193 | 'data' => $form, |
| 194 | 'limitedFields' => -1, |
| 195 | |
| 196 | ) |
| 197 | ); |
| 198 | |
| 199 | // Note: For NEW objs, we make sure a global is set here, that other update funcs can catch |
| 200 | // ... so it's essential this one runs first! |
| 201 | // this is managed in the metabox Class :) |
| 202 | if ( $form_id == -1 && ! empty( $addUpdateReturn ) && $addUpdateReturn != -1 ) { |
| 203 | |
| 204 | $form_id = $addUpdateReturn; |
| 205 | global $zbsJustInsertedMetaboxID; |
| 206 | $zbsJustInsertedMetaboxID = $form_id; |
| 207 | |
| 208 | // set this so it redirs |
| 209 | $this->newRecordNeedsRedir = true; |
| 210 | } |
| 211 | |
| 212 | // success? |
| 213 | if ( $addUpdateReturn != -1 && $addUpdateReturn > 0 ) { |
| 214 | |
| 215 | // Update Msg |
| 216 | // this adds an update message which'll go out ahead of any content |
| 217 | // This adds to metabox: $this->updateMessages['update'] = zeroBSCRM_UI2_messageHTML('info olive mini zbs-not-urgent',__('Contact Updated',"zero-bs-crm"),'','address book outline','contactUpdated'); |
| 218 | // This adds to edit page |
| 219 | $this->updateMessage(); |
| 220 | |
| 221 | // catch any non-critical messages |
| 222 | $nonCriticalMessages = $zbs->DAL->getErrors( ZBS_TYPE_FORM ); |
| 223 | if ( is_array( $nonCriticalMessages ) && count( $nonCriticalMessages ) > 0 ) { |
| 224 | $this->dalNoticeMessage( $nonCriticalMessages ); |
| 225 | } |
| 226 | } else { |
| 227 | |
| 228 | // fail somehow |
| 229 | $failMessages = $zbs->DAL->getErrors( ZBS_TYPE_FORM ); |
| 230 | |
| 231 | // show msg (retrieved from DAL err stack) |
| 232 | if ( is_array( $failMessages ) && count( $failMessages ) > 0 ) { |
| 233 | $this->dalErrorMessage( $failMessages ); |
| 234 | } else { |
| 235 | $this->dalErrorMessage( array( __( 'Insert/Update Failed with general error', 'zero-bs-crm' ) ) ); |
| 236 | } |
| 237 | |
| 238 | // pass the pre-fill: |
| 239 | global $zbsObjDataPrefill; |
| 240 | $zbsObjDataPrefill = $form; |
| 241 | |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | return $form; |
| 246 | } |
| 247 | |
| 248 | // This catches 'new' contacts + redirs to right url |
| 249 | public function post_save_data( $objID, $obj ) { |
| 250 | |
| 251 | if ( $this->newRecordNeedsRedir ) { |
| 252 | |
| 253 | global $zbsJustInsertedMetaboxID; |
| 254 | if ( ! empty( $zbsJustInsertedMetaboxID ) && $zbsJustInsertedMetaboxID > 0 ) { |
| 255 | |
| 256 | // redir |
| 257 | wp_redirect( jpcrm_esc_link( 'edit', $zbsJustInsertedMetaboxID, $this->objType ) ); |
| 258 | exit( 0 ); |
| 259 | |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | public function updateMessage() { |
| 265 | |
| 266 | global $zbs; |
| 267 | |
| 268 | // zbs-not-urgent means it'll auto hide after 1.5s |
| 269 | // genericified from DAL3.0 |
| 270 | $msg = zeroBSCRM_UI2_messageHTML( 'info olive mini zbs-not-urgent', $zbs->DAL->typeStr( $zbs->DAL->objTypeKey( $this->objType ) ) . ' ' . __( 'Updated', 'zero-bs-crm' ), '', 'address book outline', 'contactUpdated' ); |
| 271 | |
| 272 | $zbs->pageMessages[] = $msg; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | /* |
| 277 | ====================================================== |
| 278 | / Forms v3 Language Metabox |
| 279 | ====================================================== */ |
| 280 | |
| 281 | /* |
| 282 | ====================================================== |
| 283 | Forms Settings v3 Metabox |
| 284 | ====================================================== */ |
| 285 | |
| 286 | class zeroBS__Metabox_FormSettings extends zeroBS__Metabox { |
| 287 | |
| 288 | // this is for catching 'new' contacts |
| 289 | private $newRecordNeedsRedir = false; |
| 290 | |
| 291 | // this is to save + edit $fieldPrefix = 'zbsf_'; |
| 292 | private $fieldPrefix = 'zbsf_'; |
| 293 | |
| 294 | public function __construct( $plugin_file ) { |
| 295 | |
| 296 | // set these |
| 297 | // DAL3 switched for objType $this->postType = 'zerobs_customer'; |
| 298 | $this->objType = 'form'; |
| 299 | $this->metaboxID = 'zerobs-form-settings'; |
| 300 | $this->metaboxTitle = __( 'Form Settings', 'zero-bs-crm' ); |
| 301 | $this->metaboxScreen = 'zbs-add-edit-form-edit'; |
| 302 | $this->metaboxArea = 'normal'; |
| 303 | $this->metaboxLocation = 'high'; |
| 304 | $this->saveOrder = 1; |
| 305 | $this->capabilities = array( |
| 306 | |
| 307 | 'can_hide' => false, // can be hidden |
| 308 | 'areas' => array( 'normal' ), // areas can be dragged to - normal side = only areas currently |
| 309 | 'can_accept_tabs' => true, // can/can't accept tabs onto it |
| 310 | 'can_become_tab' => false, // can be added as tab |
| 311 | 'can_minimise' => true, // can be minimised |
| 312 | 'can_move' => true, // can be moved |
| 313 | |
| 314 | ); |
| 315 | |
| 316 | // call this |
| 317 | $this->initMetabox(); |
| 318 | } |
| 319 | |
| 320 | public function html( $form, $metabox ) { |
| 321 | |
| 322 | // localise ID |
| 323 | $formID = -1; |
| 324 | if ( is_array( $form ) && isset( $form['id'] ) ) { |
| 325 | $formID = (int) $form['id']; |
| 326 | } |
| 327 | |
| 328 | // pre-processing |
| 329 | $formcss = ZEROBSCRM_URL . 'css/ZeroBSCRM.admin.frontform.css'; |
| 330 | $formjs = ZEROBSCRM_URL . 'js/ZeroBSCRM.leadform.js?ver=1.17'; |
| 331 | $formRoot = get_site_url() . '/crmforms'; |
| 332 | |
| 333 | // $zbsfs = get_post_meta($formID,'zbs_form_style',true); |
| 334 | // DAL3+ saved in obj |
| 335 | $zbsfs = 'simple'; |
| 336 | if ( is_array( $form ) && isset( $form['style'] ) ) { |
| 337 | $zbsfs = $form['style']; |
| 338 | } |
| 339 | |
| 340 | // phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase |
| 341 | ?> |
| 342 | <input type="hidden" name="<?php echo esc_attr( $this->fieldPrefix ); ?>style" id="zbs_form_style_post" value="<?php echo esc_attr( $zbsfs ); ?>" /> |
| 343 | |
| 344 | <h1 class="welcomeh1"><?php esc_html_e( 'Welcome to Jetpack CRM Form Creator', 'zero-bs-crm' ); ?></h1> |
| 345 | <h3 class="welcomeh3"><?php esc_html_e( 'Choose your style for the form you wish to embed (click to choose)', 'zero-bs-crm' ); ?></h3> |
| 346 | <p class="zbs_msg"><?php esc_html_e( 'Make sure to save the form before using the shortcode', 'zero-bs-crm' ); ?>.</p> |
| 347 | <div class="zbs_shortcode_message"> |
| 348 | <p><?php esc_html_e( 'You can embed this form on this website using the shortcode below (choose your style first). To embed the form on a separate website use the embed code in the "Embed Code" box below.', 'zero-bs-crm' ); ?></p> |
| 349 | <p class="shorty"> |
| 350 | <?php |
| 351 | if ( $formID > 0 ) { |
| 352 | |
| 353 | ?> |
| 354 | [jetpackcrm_form id="<?php echo esc_attr( $formID ); ?>" style="<?php echo esc_attr( $zbsfs ); ?>"] |
| 355 | <?php |
| 356 | |
| 357 | } |
| 358 | ?> |
| 359 | </p> |
| 360 | </div> |
| 361 | |
| 362 | <div id="form-chooser"> |
| 363 | <!-- 3 styles for now - naked, simple and content grab --> |
| 364 | <div class="third" id="naked-form"> |
| 365 | <div class="naked choice |
| 366 | <?php |
| 367 | if ( $zbsfs == 'naked' ) { |
| 368 | echo 'selected';} |
| 369 | ?> |
| 370 | " data-pid="<?php echo esc_attr( $formID ); ?>" data-style="naked"> |
| 371 | <div class="blobby" style="margin-bottom:13px;"> |
| 372 | <p>Lorem Ipsum Text here</p> |
| 373 | <p>Lorem Ipsum <span class="br">s</span> Text <span class="br">s</span> here</p> |
| 374 | <p>Lorem Ipsum Text here</p> |
| 375 | <p>Lorem Ipsum Text here</p> |
| 376 | <p>Lorem Ipsum <span class="br">s</span> Text <span class="br">s</span> here</p> |
| 377 | <p>Lorem Ipsum Text here</p> |
| 378 | </div> |
| 379 | <div class="content"> |
| 380 | <div class="form-wrapper"> |
| 381 | <div class="input"> |
| 382 | <?php |
| 383 | if ( ! empty( $zbsForm['fname'] ) ) { |
| 384 | echo esc_html( $zbsForm['fname'] ); |
| 385 | } else { |
| 386 | echo 'First Name'; } |
| 387 | ?> |
| 388 | </div><div class="input"> |
| 389 | <?php |
| 390 | if ( ! empty( $zbsForm['email'] ) ) { |
| 391 | echo esc_html( $zbsForm['email'] ); |
| 392 | } else { |
| 393 | esc_html_e( 'Email', 'zero-bs-crm' ); } |
| 394 | ?> |
| 395 | </div><div class="send"> |
| 396 | <?php |
| 397 | if ( ! empty( $zbsForm['submit'] ) ) { |
| 398 | echo esc_html( $zbsForm['submit'] ); |
| 399 | } else { |
| 400 | echo 'Submit'; } |
| 401 | ?> |
| 402 | </div> |
| 403 | </div> |
| 404 | </div> |
| 405 | <div class="clear"></div> |
| 406 | <div class="blobby"> |
| 407 | <p>Lorem Ipsum Text here</p> |
| 408 | <p>Lorem Ipsum <span class="br">s</span> Text Lorem Ipsum m Ipsum <span class="br">s</span> here</p> |
| 409 | <p>Lorem Ipsum Text here</p> |
| 410 | <p>Lorem Ipsum Text here</p> |
| 411 | <p>Lorem Ipsum <span class="br">s</span> Text <span class="br">s</span> here</p> |
| 412 | <p>Lorem Ipsum Text here</p> |
| 413 | </div> |
| 414 | </div> |
| 415 | <div class="caption"><?php esc_html_e( 'Naked Style', 'zero-bs-crm' ); ?></div> |
| 416 | <div id="naked_html_form" class="hide"> |
| 417 | <div class='zbs_form_content_wrap<?php echo esc_attr( $zbsfs === 'naked' ? ' embed-selected' : '' ); ?>'><iframe src='<?php echo esc_html( $formRoot ); ?>/naked/?fid=<?php echo esc_html( $formID ); ?>' height='200px' width='700px' style='border:0!important'></iframe> |
| 418 | </div> <!-- end form content grab --> |
| 419 | </div> |
| 420 | </div> |
| 421 | |
| 422 | <div class="third" id="cgrab-form"> |
| 423 | <div class="cgrab choice |
| 424 | <?php |
| 425 | if ( $zbsfs == 'cgrab' ) { |
| 426 | echo 'selected';} |
| 427 | ?> |
| 428 | " data-pid="<?php echo esc_attr( $formID ); ?>" data-style="cgrab"> |
| 429 | <div class="blobby"> |
| 430 | <p>Lorem Ipsum Text here</p> |
| 431 | </div> |
| 432 | <div class="content"> |
| 433 | <h1> |
| 434 | <?php |
| 435 | if ( ! empty( $zbsForm['header'] ) ) { |
| 436 | echo esc_html( $zbsForm['header'] ); |
| 437 | } else { |
| 438 | echo 'Want to find out more?'; } |
| 439 | ?> |
| 440 | </h1> |
| 441 | <h3> |
| 442 | <?php |
| 443 | if ( ! empty( $zbsForm['subheader'] ) ) { |
| 444 | echo esc_html( $zbsForm['subheader'] ); |
| 445 | } else { |
| 446 | echo 'Drop us a line. We follow up on all contacts'; } |
| 447 | ?> |
| 448 | </h3> |
| 449 | <div class="form-wrapper"> |
| 450 | <div class="input"> |
| 451 | <?php |
| 452 | if ( ! empty( $zbsForm['fname'] ) ) { |
| 453 | echo esc_html( $zbsForm['fname'] ); |
| 454 | } else { |
| 455 | echo 'First Name'; } |
| 456 | ?> |
| 457 | </div> |
| 458 | <div class="input"> |
| 459 | <?php |
| 460 | if ( ! empty( $zbsForm['lname'] ) ) { |
| 461 | echo esc_html( $zbsForm['lname'] ); |
| 462 | } else { |
| 463 | echo 'Last Name'; } |
| 464 | ?> |
| 465 | </div> |
| 466 | <div class="input"> |
| 467 | <?php |
| 468 | if ( ! empty( $zbsForm['email'] ) ) { |
| 469 | echo esc_html( $zbsForm['email'] ); |
| 470 | } else { |
| 471 | echo 'Email'; } |
| 472 | ?> |
| 473 | </div> |
| 474 | <div class="textarea"> |
| 475 | <?php |
| 476 | if ( ! empty( $zbsForm['notes'] ) ) { |
| 477 | echo esc_html( $zbsForm['notes'] ); |
| 478 | } else { |
| 479 | echo 'Your Message'; } |
| 480 | ?> |
| 481 | </div> |
| 482 | <div class="send"> |
| 483 | <?php |
| 484 | if ( ! empty( $zbsForm['submit'] ) ) { |
| 485 | echo esc_html( $zbsForm['submit'] ); |
| 486 | } else { |
| 487 | echo 'Submit'; } |
| 488 | ?> |
| 489 | </div> |
| 490 | </div> |
| 491 | <div class="clear"></div> |
| 492 | <div class="trailer"> |
| 493 | <?php |
| 494 | if ( ! empty( $zbsForm['spam'] ) ) { |
| 495 | echo esc_html( $zbsForm['spam'] ); |
| 496 | } else { |
| 497 | echo 'We will not send you spam. Our team will be in touch within 24 to 48 hours Mon-Fri (but often much quicker)'; } |
| 498 | ?> |
| 499 | </div> |
| 500 | </div> |
| 501 | <div class="clear"></div> |
| 502 | <div class="blobby"> |
| 503 | <p>Lorem Ipsum <span class="br">s</span> Text Lorem Ipsum m Ipsum <span class="br">s</span> here</p> |
| 504 | </div> |
| 505 | </div> |
| 506 | <div class="caption"><?php esc_html_e( 'Content Grab', 'zero-bs-crm' ); ?></div> |
| 507 | <div id="cgrab_html_form" class="hide"> |
| 508 | <div class='zbs_form_content_wrap<?php echo esc_attr( $zbsfs === 'cgrab' ? ' embed-selected' : '' ); ?>'><iframe src='<?php echo esc_html( $formRoot ); ?>/content/?fid=<?php echo esc_html( $formID ); ?>' height='700px' width='700px' style='border:0!important'></iframe> |
| 509 | </div> <!-- end form content grab --> |
| 510 | </div> |
| 511 | |
| 512 | |
| 513 | </div> |
| 514 | |
| 515 | |
| 516 | <div class="third" id="simple-form"> |
| 517 | <div class="simple choice |
| 518 | <?php |
| 519 | if ( $zbsfs == 'simple' ) { |
| 520 | echo 'selected';} |
| 521 | ?> |
| 522 | " data-pid="<?php echo esc_attr( $formID ); ?>" data-style="simple"> |
| 523 | <div class="blobby"> |
| 524 | <p>Lorem Ipsum Text here</p> |
| 525 | <p>Lorem Ipsum <span class="br">s</span> Text <span class="br">s</span> here</p> |
| 526 | <p>Lorem Ipsum Text here</p> |
| 527 | </div> |
| 528 | <div class="content"> |
| 529 | <h1> |
| 530 | <?php |
| 531 | if ( ! empty( $zbsForm['header'] ) ) { |
| 532 | echo esc_html( $zbsForm['header'] ); |
| 533 | } else { |
| 534 | echo 'Want to find out more?'; } |
| 535 | ?> |
| 536 | </h1> |
| 537 | <h3> |
| 538 | <?php |
| 539 | if ( ! empty( $zbsForm['subheader'] ) ) { |
| 540 | echo esc_html( $zbsForm['subheader'] ); |
| 541 | } else { |
| 542 | echo 'Drop us a line. We follow up on all contacts'; } |
| 543 | ?> |
| 544 | </h3> |
| 545 | <div class="form-wrapper"> |
| 546 | <div class="input"> |
| 547 | <?php |
| 548 | if ( ! empty( $zbsForm['email'] ) ) { |
| 549 | echo esc_html( $zbsForm['email'] ); |
| 550 | } else { |
| 551 | echo 'Email'; } |
| 552 | ?> |
| 553 | </div><div class="send"> |
| 554 | <?php |
| 555 | if ( ! empty( $zbsForm['submit'] ) ) { |
| 556 | echo esc_html( $zbsForm['submit'] ); |
| 557 | } else { |
| 558 | echo 'Submit'; } |
| 559 | ?> |
| 560 | </div> |
| 561 | </div> |
| 562 | <div class="clear"></div> |
| 563 | <div class="trailer"> |
| 564 | <?php |
| 565 | if ( ! empty( $zbsForm['spam'] ) ) { |
| 566 | echo esc_html( $zbsForm['spam'] ); |
| 567 | } else { |
| 568 | echo 'We will not send you spam. Our team will be in touch within 24 to 48 hours Mon-Fri (but often much quicker)'; } |
| 569 | ?> |
| 570 | </div> |
| 571 | </div> |
| 572 | <div class="clear"></div> |
| 573 | <div class="blobby"> |
| 574 | <p>Lorem Ipsum Text here</p> |
| 575 | <p>Lorem Ipsum <span class="br">s</span> Text Lorem Ipsum m Ipsum <span class="br">s</span> here</p> |
| 576 | <p>Lorem Ipsum Text here</p> |
| 577 | </div> |
| 578 | </div> |
| 579 | <div class="caption"><?php esc_html_e( 'Simple Style', 'zero-bs-crm' ); ?></div> |
| 580 | <div id="simple_html_form" class="hide"> |
| 581 | <div class='zbs_form_content_wrap<?php echo esc_attr( $zbsfs === 'simple' ? ' embed-selected' : '' ); ?>'><iframe src='<?php echo esc_html( $formRoot ); ?>/simple/?fid=<?php echo esc_html( $formID ); ?>' height='300px' width='700px' style='border:0!important'></iframe> |
| 582 | </div> <!-- end form content grab --> |
| 583 | </div> |
| 584 | </div> |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | </div> |
| 590 | <?php /* phpcs:enable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase */ ?> |
| 591 | |
| 592 | |
| 593 | <script type="text/javascript"> |
| 594 | |
| 595 | var zeroBSCRMFormUrls = { |
| 596 | |
| 597 | 'css' : '<?php echo esc_html( $formcss ); ?>', |
| 598 | 'js' : '<?php echo esc_html( $formjs ); ?>' |
| 599 | } |
| 600 | jQuery(function(){ |
| 601 | |
| 602 | |
| 603 | //can move to a separate script at some point.... |
| 604 | jQuery('.choice').off("click").on("click",function(e){ |
| 605 | |
| 606 | |
| 607 | jQuery('#zbs-form-pre').html(''); //clear out the HTML |
| 608 | var zbsf_pid = jQuery(this).data('pid'); |
| 609 | var zbsf_style = jQuery(this).data('style'); |
| 610 | |
| 611 | jQuery('#zbs_form_style_post').val(zbsf_style); |
| 612 | if(jQuery('#'+zbsf_style+'_html_form .form-wrapper').hasClass('zbs-form-wrap')){ |
| 613 | console.log('we have a form inside the wrapper'); |
| 614 | }else{ |
| 615 | ///not used? var zbsf_action = jQuery('#zbs_form_action').data('zbsformaction'); |
| 616 | jQuery('#'+zbsf_style+'_html_form .form-wrapper').wrap("<form action='#' class='zbs-form-wrap' method='post'></form>"); |
| 617 | jQuery('#'+zbsf_style+'_html_form .form-wrapper').addClass('zbs-form-wrap'); |
| 618 | } |
| 619 | |
| 620 | var zbsf_html = jQuery('#'+zbsf_style+'_html_form .zbs_form_content_wrap').html(); //replace with proper HTML form elements |
| 621 | // switched for proper global var ^ var zbsf_html_css_link = jQuery('.zbs_form_css').data('css'); |
| 622 | var zbsf_css_link = "<link rel='stylesheet' href='"+window.zeroBSCRMFormUrls.css +"' type='text/css' media='all' />"; |
| 623 | |
| 624 | //not used? var zbsf_html_js_link = jQuery('#zbs_form_js').data('js'); |
| 625 | //not used? console.log(zbsf_html_js_link); |
| 626 | var zbsf_js_link = "<script type='text/javascript' src='>"; |
| 627 | zbsf_js_link += jQuery('.ZBSencodedJS').html(); |
| 628 | //console.log(zbsf_html_css_link); |
| 629 | var zbsf_html_encoded = zbsf_html; |
| 630 | |
| 631 | jQuery('.choice').removeClass('selected'); |
| 632 | jQuery(this).addClass('selected'); |
| 633 | jQuery('.zbs_shortcode_message').show(); |
| 634 | jQuery('.shorty').html('[jetpackcrm_form id="'+zbsf_pid+'" style="'+zbsf_style+'"]').show(); |
| 635 | |
| 636 | jQuery('#zbs-form-pre').html(zbsf_html_encoded); |
| 637 | }); |
| 638 | |
| 639 | });</script> |
| 640 | <div class="clear"></div> |
| 641 | <?php |
| 642 | } |
| 643 | |
| 644 | public function save_data( $form_id, $form ) { |
| 645 | |
| 646 | // DAL3.0+ |
| 647 | global $zbs; |
| 648 | |
| 649 | // check this |
| 650 | if ( empty( $form_id ) || $form_id < 1 ) { |
| 651 | $form_id = -1; |
| 652 | } |
| 653 | |
| 654 | /* |
| 655 | old way: |
| 656 | |
| 657 | |
| 658 | //save down the settings... |
| 659 | $zbfs = $_POST['zbs_form_style_post']; |
| 660 | update_post_meta($post->ID,'zbs_form_style', $zbfs); |
| 661 | $zbs_form_conv = get_post_meta($post->ID, 'zbs_form_conversions', true); |
| 662 | $zbs_form_views = get_post_meta($post->ID, 'zbs_form_views', true); |
| 663 | if($zbs_form_conv == ''){ |
| 664 | update_post_meta($post->ID,'zbs_form_conversions',0); |
| 665 | } |
| 666 | if($zbs_form_views == ''){ |
| 667 | update_post_meta($post->ID,'zbs_form_views',0); |
| 668 | } |
| 669 | |
| 670 | .. V3 + nothing to do here, main langlabels box does save of style (zbs_form_style_post) |
| 671 | |
| 672 | */ |
| 673 | |
| 674 | return $form; |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | /* |
| 679 | ====================================================== |
| 680 | / Forms Settings v3 Metabox |
| 681 | ====================================================== */ |
| 682 | |
| 683 | /* |
| 684 | ====================================================== |
| 685 | Forms embed v3 Metabox |
| 686 | ====================================================== */ |
| 687 | |
| 688 | class zeroBS__Metabox_FormEmbed extends zeroBS__Metabox { |
| 689 | |
| 690 | public function __construct( $plugin_file ) { |
| 691 | |
| 692 | // set these |
| 693 | // DAL3 switched for objType $this->postType = 'zerobs_customer'; |
| 694 | $this->objType = 'form'; |
| 695 | $this->metaboxID = 'zerobs-form-embed'; |
| 696 | $this->metaboxTitle = __( 'Form Embedding', 'zero-bs-crm' ); |
| 697 | $this->metaboxScreen = 'zbs-add-edit-form-edit'; |
| 698 | $this->metaboxArea = 'normal'; |
| 699 | $this->metaboxLocation = 'low'; |
| 700 | $this->saveOrder = 1; |
| 701 | $this->capabilities = array( |
| 702 | |
| 703 | 'can_hide' => false, // can be hidden |
| 704 | 'areas' => array( 'normal' ), // areas can be dragged to - normal side = only areas currently |
| 705 | 'can_accept_tabs' => true, // can/can't accept tabs onto it |
| 706 | 'can_become_tab' => false, // can be added as tab |
| 707 | 'can_minimise' => true, // can be minimised |
| 708 | 'can_move' => true, // can be moved |
| 709 | |
| 710 | ); |
| 711 | |
| 712 | // call this |
| 713 | $this->initMetabox(); |
| 714 | } |
| 715 | |
| 716 | public function html( $form, $metabox ) { |
| 717 | |
| 718 | global $zbs; |
| 719 | |
| 720 | // localise ID |
| 721 | $formID = -1; |
| 722 | if ( is_array( $form ) && isset( $form['id'] ) ) { |
| 723 | $formID = (int) $form['id']; |
| 724 | } |
| 725 | $zbsfs = 'simple'; |
| 726 | if ( is_array( $form ) && isset( $form['style'] ) ) { |
| 727 | $zbsfs = $form['style']; |
| 728 | } |
| 729 | |
| 730 | // get js url |
| 731 | $formjs = ZEROBSCRM_URL . 'js/ZeroBSCRM.leadform.js?ver=' . $zbs::VERSION; |
| 732 | |
| 733 | ?> |
| 734 | <div id="form-embed"> |
| 735 | <h1 class="welcomeh1"><?php esc_html_e( 'Embed Code', 'zero-bs-crm' ); ?></h1> |
| 736 | <h3 class="welcomeh3"><?php esc_html_e( 'Use the code below to embed this form on another site', 'zero-bs-crm' ); ?></h3> |
| 737 | <pre id="zbs-form-pre"></pre> |
| 738 | </div> |
| 739 | <script type="text/javascript"> |
| 740 | jQuery(function(){ |
| 741 | |
| 742 | // initial embed code, rest dealt with by style selection |
| 743 | var zbsembed = jQuery('.embed-selected').html(); |
| 744 | jQuery('#zbs-form-pre').html(zbsembed); |
| 745 | |
| 746 | }); |
| 747 | </script> |
| 748 | <div class='ZBSencodedJS hide'><script type='text/javascript' src='<?php echo esc_html( $formjs ); ?>'></script></div> |
| 749 | <?php |
| 750 | } |
| 751 | } |
| 752 | /* |
| 753 | ====================================================== |
| 754 | / Forms embed v3 Metabox |
| 755 | ====================================================== */ |
| 756 | |
| 757 | /* |
| 758 | ====================================================== |
| 759 | Forms get more fields v3 Metabox |
| 760 | ====================================================== */ |
| 761 | |
| 762 | class zeroBS__Metabox_FormMoreFields extends zeroBS__Metabox { |
| 763 | |
| 764 | public function __construct( $plugin_file ) { |
| 765 | |
| 766 | // set these |
| 767 | // DAL3 switched for objType $this->postType = 'zerobs_customer'; |
| 768 | $this->objType = 'form'; |
| 769 | $this->metaboxID = 'zerobs-form-morefields'; |
| 770 | $this->metaboxTitle = __( 'Want More Fields?', 'zero-bs-crm' ); |
| 771 | $this->metaboxScreen = 'zbs-add-edit-form-edit'; |
| 772 | $this->metaboxArea = 'normal'; |
| 773 | $this->metaboxLocation = 'low'; |
| 774 | $this->saveOrder = 1; |
| 775 | $this->capabilities = array( |
| 776 | |
| 777 | 'can_hide' => false, // can be hidden |
| 778 | 'areas' => array( 'normal' ), // areas can be dragged to - normal side = only areas currently |
| 779 | 'can_accept_tabs' => true, // can/can't accept tabs onto it |
| 780 | 'can_become_tab' => false, // can be added as tab |
| 781 | 'can_minimise' => true, // can be minimised |
| 782 | 'can_move' => true, // can be moved |
| 783 | |
| 784 | ); |
| 785 | |
| 786 | ##WLREMOVE |
| 787 | $this->initMetabox(); |
| 788 | ##/WLREMOVE |
| 789 | } |
| 790 | |
| 791 | public function html( $form, $metabox ) { |
| 792 | |
| 793 | // this was in as js, wh converted for v3+ |
| 794 | $moreTitle = __( 'Need More Fields?', 'zero-bs-crm' ); |
| 795 | $moreDesc = __( 'Jetpack CRM forms cover simple use contact and subscription forms, but if you need more we suggest using a form plugin like Contact Form 7 or Gravity Forms:', 'zero-bs-crm' ) . ' <a href="https://jetpackcrm.com/feature/forms/#benefit" target="_blank">' . __( 'See Options', 'zero-bs-crm' ) . '</a>'; |
| 796 | $moreFinal = '<div id="form-upsell"><h1 class="welcomeh1">' . $moreTitle . '</h1><p style="text-align:center;padding: 2em;font-size: 1.2em;padding-top: 0;">' . $moreDesc . '</p></div>'; |
| 797 | |
| 798 | echo $moreFinal; |
| 799 | } |
| 800 | } |
| 801 | /* |
| 802 | ====================================================== |
| 803 | / Forms get more fields v3 Metabox |
| 804 | ====================================================== */ |
| 805 | |
| 806 | /* |
| 807 | ====================================================== |
| 808 | Form Action Metabox |
| 809 | ====================================================== */ |
| 810 | |
| 811 | class zeroBS__Metabox_FormActions extends zeroBS__Metabox { |
| 812 | |
| 813 | public function __construct( $plugin_file ) { |
| 814 | |
| 815 | // set these |
| 816 | $this->objType = 'form'; |
| 817 | $this->metaboxID = 'zerobs-form-actions'; |
| 818 | $this->metaboxTitle = __( 'Form', 'zero-bs-crm' ) . ' ' . __( 'Actions', 'zero-bs-crm' ); // will be headless anyhow |
| 819 | $this->headless = true; |
| 820 | $this->metaboxScreen = 'zbs-add-edit-form-edit'; |
| 821 | $this->metaboxArea = 'side'; |
| 822 | $this->metaboxLocation = 'high'; |
| 823 | $this->saveOrder = 1; |
| 824 | $this->capabilities = array( |
| 825 | |
| 826 | 'can_hide' => false, // can be hidden |
| 827 | 'areas' => array( 'side' ), // areas can be dragged to - normal side = only areas currently |
| 828 | 'can_accept_tabs' => true, // can/can't accept tabs onto it |
| 829 | 'can_become_tab' => false, // can be added as tab |
| 830 | 'can_minimise' => true, // can be minimised |
| 831 | 'can_move' => true, // can be moved |
| 832 | |
| 833 | ); |
| 834 | |
| 835 | // call this |
| 836 | $this->initMetabox(); |
| 837 | } |
| 838 | |
| 839 | public function html( $form, $metabox ) { |
| 840 | |
| 841 | ?> |
| 842 | <div class="zbs-generic-save-wrap"> |
| 843 | |
| 844 | <div class="ui medium dividing header"><i class="save icon"></i> <?php esc_html_e( 'Form Actions', 'zero-bs-crm' ); ?></div> |
| 845 | |
| 846 | <?php |
| 847 | |
| 848 | // localise ID & content |
| 849 | $formID = -1; |
| 850 | if ( is_array( $form ) && isset( $form['id'] ) ) { |
| 851 | $formID = (int) $form['id']; |
| 852 | } |
| 853 | |
| 854 | #} if a saved obj... |
| 855 | if ( $formID > 0 ) { // existing |
| 856 | |
| 857 | ?> |
| 858 | |
| 859 | <div class="zbs-form-actions-bottom zbs-objedit-actions-bottom"> |
| 860 | |
| 861 | <button class="ui button black" type="button" id="zbs-edit-save"><?php esc_html_e( 'Update', 'zero-bs-crm' ); ?> <?php esc_html_e( 'Form', 'zero-bs-crm' ); ?></button> |
| 862 | |
| 863 | <?php |
| 864 | |
| 865 | // delete? |
| 866 | |
| 867 | // for now just check if can modify, later better, granular perms. |
| 868 | if ( zeroBSCRM_permsQuotes() ) { |
| 869 | ?> |
| 870 | <div id="zbs-form-actions-delete" class="zbs-objedit-actions-delete"> |
| 871 | <a class="submitdelete deletion" href="<?php echo jpcrm_esc_link( 'delete', $formID, 'form' ); ?>"><?php esc_html_e( 'Delete Permanently', 'zero-bs-crm' ); ?></a> |
| 872 | </div> |
| 873 | <?php } // can delete ?> |
| 874 | |
| 875 | <div class='clear'></div> |
| 876 | |
| 877 | </div> |
| 878 | <?php |
| 879 | |
| 880 | } else { |
| 881 | |
| 882 | // NEW form |
| 883 | ?> |
| 884 | |
| 885 | <div class="zbs-form-actions-bottom zbs-objedit-actions-bottom"> |
| 886 | |
| 887 | <button class="ui button black" type="button" id="zbs-edit-save"><?php esc_html_e( 'Save', 'zero-bs-crm' ); ?> <?php esc_html_e( 'Form', 'zero-bs-crm' ); ?></button> |
| 888 | |
| 889 | </div> |
| 890 | |
| 891 | <?php |
| 892 | |
| 893 | } |
| 894 | |
| 895 | ?> |
| 896 | </div> |
| 897 | <?php |
| 898 | // / .zbs-generic-save-wrap |
| 899 | } // html |
| 900 | |
| 901 | // saved via main metabox |
| 902 | } |
| 903 | |
| 904 | /** |
| 905 | * End of Form Action Metabox |
| 906 | */ |