1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868: 869: 870: 871: 872: 873: 874: 875: 876: 877: 878: 879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896: 897: 898: 899: 900: 901: 902: 903: 904: 905: 906: 907: 908: 909: 910: 911: 912: 913: 914: 915: 916: 917: 918: 919: 920: 921: 922: 923: 924: 925: 926: 927: 928: 929: 930: 931: 932: 933: 934: 935: 936: 937: 938: 939: 940: 941: 942: 943: 944: 945: 946: 947: 948: 949: 950: 951: 952: 953: 954: 955: 956: 957: 958: 959: 960: 961: 962: 963: 964: 965: 966: 967: 968: 969: 970: 971: 972: 973: 974: 975: 976: 977: 978: 979: 980: 981: 982: 983: 984: 985: 986: 987: 988: 989: 990: 991: 992: 993: 994: 995: 996: 997: 998: 999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211:
<?php
class Landing_Pages_Metaboxes {
static $current_vid;
static $current_template;
static $variations;
static $is_new;
static $is_clone;
static $content_area;
public function __construct() {
self::add_hooks();
}
public static function add_hooks() {
add_action( 'admin_init' , array( __CLASS__ , 'run_actions' ) );
add_action( 'admin_enqueue_scripts' , array( __CLASS__ , 'enqueue_scripts' ) );
add_action( 'add_meta_boxes' , array( __CLASS__ , 'register_metaboxes' ) );
add_action( 'edit_form_after_title', array( __CLASS__ , 'display_variations_nav_metabox' ) );
add_action( 'edit_form_after_title', array( __CLASS__ , 'display_main_headline' ) );
add_filter( 'enter_title_here', array( __CLASS__, 'filter_default_title_text' ) , 10, 2 );
add_filter( 'wp_default_editor', array( __CLASS__ , 'filter_default_wysiwyg_view' ) );
add_action( 'wp_ajax_lp_get_template_meta' , array( __CLASS__ , 'ajax_get_template_metabox_html' ));
add_action('admin_notices', array( __CLASS__ , 'display_select_template_container' ) );
add_action('save_post', array( __CLASS__ , 'save_landing_page' ) );
add_filter('wpseo_metabox_prio', array( __CLASS__ , 'set_wpseo_priority' ));
}
public static function register_metaboxes() {
global $post;
if ( !isset($post) || $post->post_type!='landing-page') {
return;
}
if($post->post_status !== 'draft') {
add_meta_box(
'lp-thumbnail-sidebar-preview',
__( 'Template Preview', 'landing-pages'),
array( __CLASS__ , 'display_template_preview_metabox' ),
'landing-page' ,
'side',
'high'
);
}
add_meta_box(
'lp_2_form_content',
__('Insert Form / Conversion Content', 'landing-pages'),
array( __CLASS__ , 'display_conversion_area_metabox' ),
'landing-page',
'normal',
'high'
);
add_meta_box(
'lp_metabox_select_template',
__( 'Template Selection', 'landing-pages'),
array( __CLASS__ , 'display_select_template' ),
'landing-page',
'normal',
'high'
);
$extension_data = Landing_Pages_Load_Extensions::get_extended_data();;
$current_template = Landing_Pages_Variations::get_current_template($post->ID);
foreach ($extension_data as $key => $data) {
if ( $key != $current_template || ( isset($data['info']['data_type']) && strstr( $data['info']['data_type'] , 'acf') ) ) {
continue;
}
$template_name = ucwords(str_replace('-', ' ', $key));
$id = strtolower(str_replace(' ', '-', $key));
add_meta_box(
"lp_{$id}_custom_meta_box",
"<small>$template_name</small>",
array( __CLASS__ , 'display_extended_metabox' ),
'landing-page',
'normal',
'default',
array('key' => $key)
);
}
add_meta_box(
'lp_3_custom_css',
__( 'Custom CSS' , 'landing-pages') ,
array( __CLASS__ , 'display_custom_css_metabox' ),
'landing-page',
'normal',
'low'
);
add_meta_box(
'lp_3_custom_js',
__('Custom JS' , 'landing-pages') ,
array( __CLASS__ , 'display_custom_js_metabox' ),
'landing-page',
'normal',
'low'
);
add_meta_box(
'lp_4_variation_notes',
__('Variation Notes' , 'landing-pages') ,
array( __CLASS__ , 'display_variation_notes' ),
'landing-page',
'normal',
'low'
);
add_meta_box(
'lp_ab_display_stats_metabox',
__( 'A/B Testing', 'landing-pages'),
array( __CLASS__ , 'display_quick_stats_metabox' ) ,
'landing-page' ,
'side',
'high'
);
foreach ($extension_data as $key => $data) {
if ( !isset( $data['info']['data_type']) || $data['info']['data_type'] != 'metabox') {
continue;
}
$id = "metabox-" . $key;
(isset($data['info']['label'])) ? $name = $data['info']['label'] : $name = ucwords(str_replace(array('-', 'ext '), ' ', $key) . " Extension Options");
(isset($data['info']['position'])) ? $position = $data['info']['position'] : $position = "normal";
(isset($data['info']['priority'])) ? $priority = $data['info']['priority'] : $priority = "default";
add_meta_box(
"lp_{$id}_custom_meta_box",
$name,
array( __CLASS__ , 'display_extended_metabox' ),
'landing-page',
$position,
$priority,
array('key' => $key)
);
}
add_meta_box(
'postexcerpt',
__('Short Description', 'landing-pages'),
'post_excerpt_meta_box',
'landing-page',
'normal',
'core'
);
add_meta_box(
'lp_conversion_tracking',
__('Additional Resources', 'landing-pages'),
array( __CLASS__ , 'display_additional_resources' ),
'landing-page',
'normal',
'low'
);
}
public static function run_actions() {
if (!isset($_GET['post'])) {
return;
}
$post = get_post( $_GET['post'] );
if ( !isset($post) || $post->post_type != 'landing-page') {
return;
}
self::$current_vid = Landing_Pages_Variations::get_current_variation_id( $post->ID );
self::$variations =Landing_Pages_Variations::get_variations( $post->ID );
if (isset($_GET['ab-action']) && $_GET['ab-action'] == 'delete-variation') {
Landing_Pages_Variations::delete_variation( $post->ID , intval($_REQUEST['action-variation-id']) );
}
if (isset($_GET['ab-action']) && $_GET['ab-action'] == 'pause-variation') {
Landing_Pages_Variations::pause_variation( $post->ID , intval($_REQUEST['action-variation-id']) );
}
if (isset($_GET['ab-action']) && $_GET['ab-action'] == 'play-variation') {
Landing_Pages_Variations::play_variation( $post->ID , intval($_REQUEST['action-variation-id']) );
}
self::$is_new = (isset($_GET['new-variation'])) ? 1 : 0;
self::$is_clone = (isset($_GET['clone'])) ? $_GET['clone'] : null;
self::$content_area = Landing_Pages_Variations::get_post_content( $post->ID );
(isset($_GET['new-variation']) && $_GET['new-variation'] == 1) ? $new_variation = 1 : $new_variation = 0;
if (self::$is_new ) {
$_SESSION['lp_ab_test_open_variation'] = Landing_Pages_Variations::prepare_new_variation_id( $post->ID );
}
}
public static function enqueue_scripts( $hook ) {
global $post;
$screen = get_current_screen();
if ( !isset($screen) || $screen->id != 'landing-page') {
return;
}
wp_enqueue_script(array('jquery', 'jqueryui', 'editor', 'thickbox', 'media-upload'));
wp_enqueue_style('edit-landing-page', LANDINGPAGES_URLPATH . 'assets/css/admin/edit-landing-page.css', array() , null);
wp_enqueue_script('lp-js-metaboxes', LANDINGPAGES_URLPATH . 'assets/js/admin/admin.metaboxes.js', array() , null);
wp_enqueue_script('jpicker', LANDINGPAGES_URLPATH . 'assets/libraries/jpicker/jpicker-1.1.6.min.js', array() , null);
wp_localize_script( 'jpicker', 'jpicker', array( 'thispath' => LANDINGPAGES_URLPATH.'assets/libraries/jpicker/images/' ));
wp_enqueue_style('jpicker-css', LANDINGPAGES_URLPATH . 'assets/libraries/jpicker/css/jPicker-1.1.6.min.css', array() , null);
$template_data = Landing_Pages_Load_Extensions::get_extended_data();;
$template_data_json = json_encode($template_data);
$template = Landing_Pages_Variations::get_current_template( $post->ID );
$params = array('selected_template'=>$template, 'templates'=>$template_data_json);
wp_localize_script('lp-js-metaboxes', 'data', $params);
if ( isset($template_data[$template]['info']['data_type']) && strstr( $template_data[$template]['info']['data_type'] , 'acf')){
wp_enqueue_style('lp-acf-template', LANDINGPAGES_URLPATH . 'assets/css/admin/acf-hide-wp-elements.css' , array() , null );
}
wp_enqueue_style('inbound-metaboxes', INBOUNDNOW_SHARED_URLPATH . 'assets/css/admin/inbound-metaboxes.css' , array() , null);
wp_enqueue_script( 'lp-admin-clear-stats-ajax-request', LANDINGPAGES_URLPATH . 'assets/js/ajax.clearstats.js', array( 'jquery' ) , null );
wp_localize_script( 'lp-admin-clear-stats-ajax-request', 'ajaxadmin', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'lp_clear_nonce' => wp_create_nonce('lp-clear-nonce') ) );
wp_enqueue_script('jquery-zoomer', LANDINGPAGES_URLPATH . 'assets/libraries/jquery.zoomer.js', array() , null);
wp_enqueue_script('lp-post-edit-ui', LANDINGPAGES_URLPATH . 'assets/js/admin/admin.post-edit.js', array() , null);
wp_localize_script( 'lp-post-edit-ui', 'lp_post_edit_ui', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'post_id' => $post->ID , 'wp_landing_page_meta_nonce' => wp_create_nonce('wp-landing-page-meta-nonce'), 'lp_template_nonce' => wp_create_nonce('lp-nonce') ) );
wp_enqueue_style('admin-post-edit-css', LANDINGPAGES_URLPATH . 'assets/css/admin-post-edit.css', array() , null);
wp_register_style('font-awesome', INBOUNDNOW_SHARED_URLPATH.'assets/fonts/fontawesome/css/font-awesome.min.css', array() , null);
wp_enqueue_style('font-awesome');
wp_enqueue_script('sweet-alert', INBOUNDNOW_SHARED_URLPATH.'assets/includes/SweetAlert/sweetalert.min.js', array() , null);
$localized = array(
'title' => __("Are you sure?","landing-pages"),
'text' => __("Are you sure you want to select this template?","landing-pages"),
'confirmButtonText' => __("Yes","landing-pages"),
'confirmTextTitle' => __("Deleted!","landing-pages"),
'confirmText' => __("Your imaginary file has been deleted.","landing-pages"),
'waitTitle' => __("Please wait","landing-pages"),
'waitText' => __("We are peparing your template now.","landing-pages"),
'waitImage' => INBOUNDNOW_SHARED_URLPATH .'assets/includes/SweetAlert/loading_colorful.gif'
);
wp_localize_script('sweet-alert', 'sweetalert', $localized );
wp_enqueue_style('sweet-alert', INBOUNDNOW_SHARED_URLPATH.'assets/includes/SweetAlert/sweetalert.css', array() , null);
wp_enqueue_style('lp-ab-testing-admin', LANDINGPAGES_URLPATH . 'assets/css/admin-ab-testing.css', array() , null);
wp_enqueue_script('lp-ab-testing-admin', LANDINGPAGES_URLPATH . 'assets/js/admin/admin.post-edit-ab-testing.js', array('jquery') , null );
wp_localize_script('lp-ab-testing-admin', 'variation', array('pid' => $post->ID , 'vid' => self::$current_vid, 'new_variation' => self::$is_new , 'variations' => self::$variations, 'content_area' => self::$content_area));
wp_enqueue_script( 'jquery-time-picker', LANDINGPAGES_URLPATH . 'assets/libraries/datetimepicker/jquery.datetimepicker.js', array('jquery') , null );
wp_enqueue_style( 'jquery-time-picker', LANDINGPAGES_URLPATH . 'assets/libraries/datetimepicker/jquery.datetimepicker.css' , array() , null );
wp_enqueue_script( 'jquery-date-picker', LANDINGPAGES_URLPATH . 'assets/libraries/datetimepicker/picker_functions.js', array('jquery') , null );
if ( $hook == 'post-new.php' ) {
wp_enqueue_script('lp-js-create-new-lander', LANDINGPAGES_URLPATH . 'assets/js/admin/admin.post-new.js', array('jquery'), null, true );
wp_localize_script( 'lp-js-create-new-lander', 'lp_post_new_ui', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'post_id' => $post->ID , 'wp_landing_page_meta_nonce' => wp_create_nonce('lp_nonce') , 'LANDINGPAGES_URLPATH' => LANDINGPAGES_URLPATH ) );
wp_enqueue_style('lp-css-post-new', LANDINGPAGES_URLPATH . 'assets/css/admin-post-new.css' , array() , null);
}
if ( $hook == 'post.php' ) {
wp_enqueue_script('lp-change-template', LANDINGPAGES_URLPATH . 'assets/js/admin/admin.post.js', array('jquery'), null, true );
}
}
public static function filter_default_wysiwyg_view( $default ) {
global $post;
if ( !isset($post) || $post->post_type != 'landing-page' ) {
return $default;
}
return 'html';
}
public static function filter_default_title_text( $text , $post ) {
if ($post->post_type == 'landing-page') {
return __( 'Enter Landing Page Description' , 'landing-pages');
} else {
return $text;
}
}
public static function display_main_headline() {
global $post;
if (!isset($post) || $post->post_type !='landing-page' ) {
return;
}
$variation_id = Landing_Pages_Variations::get_current_variation_id( );
$main_headline = Landing_Pages_Variations::get_main_headline( $post->ID , $variation_id );
?>
<div id="main-title-area">
<input type="text" name="<?php echo Landing_Pages_Variations::prepare_input_id( 'lp-main-headline'); ?>" placeholder="<?php _e('Enter Headline' , 'landing-pages'); ?>" id="lp-main-headline" value="<?php echo $main_headline; ?>" title="'. __('This headline will appear in the landing page template.' , 'landing-pages') .'">
</div>
<div id="switch-lp">0</div>
<?php
if(isset($_REQUEST['frontend']) && $_REQUEST['frontend'] == 'true') {
echo('<input type="hidden" name="frontend" id="frontend-on" value="true" />');
}
}
public static function display_select_template() {
global $post;
$template = Landing_Pages_Variations::get_current_template( $post->ID );
$name = Landing_Pages_Variations::prepare_input_id( 'lp-selected-template' );
echo "<input type='hidden' name='lp_lp_custom_fields_nonce' value='".wp_create_nonce('lp-nonce')."' />";
?>
<div id="lp_template_change"><h2>
<a class="button" id="lp-change-template-button"><?php _e( 'Choose Another Template' , 'landing-pages'); ?></a>
</div>
<input type='hidden' id='lp_select_template' name='<?php echo $name; ?>' value='<?php echo $template; ?>'>
<div id="template-display-options">
</div>
<?php
}
public static function display_variations_nav_metabox() {
global $post;
global $post;
if ( !isset($post) || $post->post_type!='landing-page') {
return;
}
$current_variation_id = Landing_Pages_Variations::get_current_variation_id($post->ID);
echo "<input type='hidden' id='open_variation' value='{$current_variation_id}'>";
echo "<input type='hidden' name='lp-variation-id' id='lp-variation-id' value='{$current_variation_id}'>";
$variations = Landing_Pages_Variations::get_variations($post->ID);
$new_variation_id = Landing_Pages_Variations::prepare_new_variation_id($post->ID);
if ($current_variation_id > 0 || self::$is_new ) {
$first_class = 'inactive';
} else {
$first_class = 'active';
}
echo '<h2 class="nav-tab-wrapper a_b_tabs">';
foreach ($variations as $i => $vid) {
$letter = Landing_Pages_Variations::vid_to_letter( $post->ID , $i);
$pre = ($i < 1) ? __('Version ', 'landing-pages') : '';
if ($current_variation_id == $vid && !isset($_GET['new-variation'])) {
$cur_class = 'active';
} else {
$cur_class = 'inactive';
}
$permalink = get_permalink($post->ID) . '?' . '&lp-variation-id=' . $vid ;
echo '<a href="?post=' . $post->ID . '&lp-variation-id=' . $vid . '&action=edit" class="lp-nav-tab nav-tab nav-tab-special-' . $cur_class . '" data-permalink="'.$permalink.'" id="tabs-add-variation" target="_parent">' . $pre . $letter . '</a>';
}
if (!isset($_GET['new-variation'])) {
echo '<a href="?post=' . $post->ID . '&lp-variation-id=' . $new_variation_id . '&action=edit&new-variation=1" class="lp-nav-tab nav-tab nav-tab-special-inactive nav-tab-add-new-variation" id="tabs-add-variation">' . __('Add New Variation', 'landing-pages') . '</a>';
} else {
$variation_count = $i + 1;
$letter = Landing_Pages_Variations::vid_to_letter( $post->ID, $variation_count);
echo '<a href="?post=' . $post->ID . '&lp-variation-id=' . $new_variation_id . '&action=edit" class="lp-nav-tab nav-tab nav-tab-special-active" id="tabs-add-variation">' . $letter . '</a>';
}
$edit_link = (isset($_GET['lp-variation-id'])) ? '?lp-variation-id=' . $_GET['lp-variation-id'] . '' : '?lp-variation-id=0';
$post_link = get_permalink($post->ID);
$post_link = preg_replace('/\?.*/', '', $post_link);
echo "<a rel='" . $post_link . "' id='launch-visual-editer' class='button-primary new-save-lp-frontend' href='$post_link$edit_link&inbound-customizer=on'>" . __('Launch Visual Editor', 'landing-pages') . "</a>";
echo '</h2>';
}
public static function display_quick_stats_metabox() {
global $post;
$variations = Landing_Pages_Variations::get_variations($post->ID);
?>
<div>
<style type="text/css">
</style>
<div class="inside" id="a-b-testing">
<div id="stat-box">
<?php
if (isset($_GET['new_meta_key']) && is_numeric($_GET['new_meta_key']) ) {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
function isNumber (o) {
return ! isNaN (o-0) && o !== null && o !== "" && o !== false;
}
var new_meta_key = "<?php echo $_GET['new_meta_key'];?>";
jQuery('#template-display-options input[type=text], #template-display-options select, #template-display-options input[type=radio], #template-display-options textarea').each(function(){
var this_id = jQuery(this).attr("id");
var final_number = this_id.match(/[^-]+$/g);
var new_id = this_id.replace(/[^-]+$/g, new_meta_key);
var is_number = isNumber(final_number);
if (is_number === false) {
jQuery(this).attr("id", this_id + "-" + new_meta_key);
jQuery(this).attr("name", this_id + "-" + new_meta_key);
} else {
jQuery(this).attr("id", new_id);
jQuery(this).attr("name", new_id);
}
});
});
</script>
<?php
}
$howmany = count($variations);
foreach ($variations as $key => $vid) {
$variation_status = Landing_Pages_Variations::get_variation_status($post->ID, $vid);
$variation_status_class = ($variation_status == 1) ? "variation-on" : 'variation-off';
$permalink = Landing_Pages_Variations::get_variation_permalink($post->ID, $vid);
$impressions = Landing_Pages_Variations::get_impressions($post->ID, $vid);
$conversions = Landing_Pages_Variations::get_conversions($post->ID, $vid);
$conversion_rate = Landing_Pages_Variations::get_conversion_rate($post->ID, $vid);
$title = Landing_Pages_Variations::get_main_headline($post->ID, $vid);
?>
<div id="lp-variation-<?php echo Landing_Pages_Variations::vid_to_letter( $post->ID , $key); ?>"
class="variation-row <?php echo $variation_status_class; ?>">
<div class='varation-header'>
<span class='variation-name'><?php _e('Variation', 'landing-pages'); ?> <span
class='stat-letter'><?php echo Landing_Pages_Variations::vid_to_letter( $post->ID , $key); ?></span>
<?php
if ($variation_status != 1) {
?>
<span class='is-paused'>(<?php _e('Paused', 'landing-pages') ?>)</span>
<?php
}
?>
</span>
<span class="settings_icon"> </span>
<span class="settings_wrapper">
<span class="settings_wrapper_heading">Variation Settings</span>
<ul class="settings_list_li">
<li class="settings_edit">
<span class='stat-menu-edit'>
<a title="<?php _e('Edit this variation', 'landing-pages'); ?>" href='?post=<?php echo $post->ID; ?>&action=edit&action-variation-id=<?php echo $vid; ?>'>
<?php _e('Edit', 'landing-pages'); ?>
</a>
</span>
</li>
<li class="settings_preview">
<span class='stat-menu-preview'>
<a title="<?php _e('Preview this variation', 'landing-pages'); ?>" class='thickbox' href='<?php echo $permalink; ?>&iframe_window=on&post_id=<?php echo $post->ID; ?>&TB_iframe=true&width=1503&height=467' target='_blank'>
<?php _e('Preview', 'landing-pages'); ?>
</a>
</span>
</li>
<li class="settings_clone">
<span class='stat-menu-clone'>
<a title="<?php _e('Clone this variation', 'landing-pages'); ?>" href='?post=<?php echo $post->ID; ?>&action=edit&new-variation=1&clone=<?php echo $vid; ?>&new_meta_key=<?php echo $howmany; ?>'>
<?php _e('Clone', 'landing-pages'); ?>
</a>
</span>
</li>
<li class="settings_delete">
<span class='stat-control-delete'>
<a title="<?php _e('Delete this variation', 'landing-pages'); ?>" href='?post=<?php echo $post->ID; ?>&action=edit&action-variation-id=<?php echo $vid; ?>&ab-action=delete-variation'>
<?php _e('Delete', 'landing-pages'); ?>
</a>
</span>
</li>
<li class="settings_clearstat">
<!-- CLEAR STATS START -->
<span class="lp-delete-var-stats" data-letter='<?php echo Landing_Pages_Variations::vid_to_letter( $post->ID , $key); ?>' data-vid='<?php echo $vid; ?>' rel='<?php echo $post->ID; ?>' title="<?php _e('Delete this variations stats', 'landing-pages'); ?>">
<?php _e('Clear Stats', 'landing-pages'); ?>
</span>
<!-- CLEAR STAT END --></li>
</ul>
</span>
<!-- PAUSE START -->
<span class='stat-control-pause'><a title="<?php _e('Pause this variation', 'landing-pages'); ?>"
href='?post=<?php echo $post->ID; ?>&action=edit&action-variation-id=<?php echo $vid; ?>&ab-action=pause-variation'> </a></span>
<!-- PAUSE END -->
<!-- PLAY START -->
<span class='stat-seperator pause-sep'>|</span>
<span class='stat-control-play'><a
title="<?php _e('Turn this variation on', 'landing-pages'); ?>"
href='?post=<?php echo $post->ID; ?>&action=edit&action-variation-id=<?php echo $vid; ?>&ab-action=play-variation'> </a></span>
<!-- PLAY END -->
</div>
<div class="stat-row">
<div class='stat-stats' colspan='2'>
<div class='stat-container-impressions number-box'>
<span class="stat-id"><?php _e('Views', 'landing-pages'); ?> </span>
<span class='stat-span-impressions'><?php echo $impressions; ?></span>
</div>
<div class='stat-container-conversions number-box'>
<span class="stat-id"><?php _e('Conversions', 'landing-pages'); ?></span> <span class='stat-span-conversions'><?php echo $conversions; ?></span>
</span>
</div>
<div class='stat-container-conversion_rate number-box'>
<span class="stat-id rate"><?php _e('Conversion Rate', 'landing-pages'); ?></span>
<span class='stat-span-conversion_rate'><?php echo $conversion_rate; ?></span>
</div>
</div>
</div>
<div class="stat-row">
<div class='stat-menu-container'>
<?php do_action('lp_ab_testing_stats_menu_post'); ?>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
<?php
}
public static function display_conversion_area_metabox(){
global $post;
$meta_box_id = 'lp_2_form_content';
$editor_id = 'landing-page-myeditor';
echo "
<style type='text/css'>
#$meta_box_id #edButtonHTML, #$meta_box_id #edButtonPreview {background-color: #F1F1F1; border-color: #DFDFDF #DFDFDF #CCC; color: #999;}
#$editor_id{width:100%;}
#$meta_box_id #editorcontainer{background:#fff !important;}
#$meta_box_id #editor_id_fullscreen{display:none;}
</style>
<script type='text/javascript'>
jQuery(function($){
jQuery('#lp_2_form_content #editor-toolbar > a').click(function(){
jQuery('#$meta_box_id #editor-toolbar > a').removeClass('active');
jQuery(this).addClass('active');
});
if(jQuery('#lp_2_form_content #edButtonPreview').hasClass('active')){
jQuery('#$meta_box_id #ed_toolbar').hide();
}
jQuery('#lp_2_form_content #edButtonPreview').click(function(){
jQuery('#$meta_box_id #ed_toolbar').hide();
});
jQuery('#lp_2_form_content #edButtonHTML').click(function(){
jQuery('#$meta_box_id #ed_toolbar').show();
});
/*Tell the uploader to insert content into the correct WYSIWYG editor */
jQuery('#media-buttons a').bind('click', function(){
var customEditor = jQuery(this).parents('#$meta_box_id');
if(customEditor.length > 0){
edCanvas = document.getElementById('$editor_id');
}
else{
edCanvas = document.getElementById('content');
}
});
});
</script>
";
$conversion_area = Landing_Pages_Variations::get_conversion_area( $post->ID );
wp_editor($conversion_area, $editor_id);
echo "<div style='clear:both; display:block;'></div>";
echo "<div style='width:100%;text-align:right;margin-top:11px;'><div class='lp_tooltip' title=\"". __('To help track conversions Landing Pages Plugin will automatically add a tracking class to forms. If you would like to track a link add this class to it' , 'landing-pages') ." class='inbound-track-link'\" ></div></div>";
}
public static function display_custom_css_metabox() {
global $post;
echo sprintf(
__('%sCustom CSS may be required to customize this landing page.%s%s %sFormat%s: #element-id { display:none !important; }%s' , 'landing-pages') ,
'<em>' , '</em>' , '<strong>' , '<u>' , '</u>' ,'</strong>'
);
$custom_css_name = Landing_Pages_Variations::prepare_input_id( 'lp-custom-css' );
$custom_css = Landing_Pages_Variations::get_custom_css( $post->ID );
echo '<textarea name="'.$custom_css_name.'" id="lp-custom-css" rows="5" cols="30" style="width:100%;">'. $custom_css .'</textarea>';
}
public static function display_custom_js_metabox() {
global $post;
$custom_js_name = Landing_Pages_Variations::prepare_input_id( 'lp-custom-js' );
$custom_js = Landing_Pages_Variations::get_custom_js( $post->ID );
echo '<textarea name="'.$custom_js_name.'" id="lp_custom_js" rows="5" cols="30" style="width:100%;">'.$custom_js.'</textarea>';
}
public static function display_variation_notes() {
global $post;
$variation_id = Landing_Pages_Variations::get_current_variation_id( );
$variation_notes = Landing_Pages_Variations::get_variation_notes( $post->ID , $variation_id );
$variation_notes_id = Landing_Pages_Variations::prepare_input_id( 'lp-variation-notes');
echo '<textarea name="'.$variation_notes_id.'" id="lp_variation_notes" rows="5" cols="30" style="width:100%;">'.$variation_notes.'</textarea>';
}
public static function display_select_template_container() {
global $post;
if (!isset($post) || $post->post_type != 'landing-page') {
return false;
}
$screen = get_current_screen();
$toggle = ($screen->parent_file != 'edit.php?post_type=landing-page' || $screen->action != 'add') ? "display:none" : "";
$extension_data = Landing_Pages_Load_Extensions::get_extended_data();;
$extension_data_cats = Landing_Pages_Load_Extensions::get_template_categories();
unset($extension_data['lp']);
ksort($extension_data_cats);
$uploads = wp_upload_dir();
$uploads_path = $uploads['basedir'];
$extended_path = $uploads_path . '/landing-pages/templates/';
self::$current_template = Landing_Pages_Variations::get_current_template($post->ID);
echo "<div class='lp-template-selector-container' style='{$toggle}'>";
echo "<div class='lp-selection-heading'>";
echo "<h1>" . __('Select Your Landing Page Template!', 'landing-pages') . "</h1>";
echo '<a class="button-secondary" style="display:none;" id="lp-cancel-selection">' . __('Cancel Template Change', 'landing-pages') . '</a>';
echo "</div>";
echo '<ul id="template-filter" >';
echo '<li class="button-primary button"><a href="#" data-filter=".template-item-boxes">' . __('All', 'landing-pages') . '</a></li>';
echo '<li class="button-primary button"><a href="#" data-filter=".theme">' . __('Theme', 'landing-pages') . '</a></li>';
$categories = array('Theme');
foreach ($extension_data_cats as $cat) {
$slug = str_replace(' ', '-', $cat['value']);
$slug = strtolower($slug);
$cat['value'] = ucwords($cat['value']);
if (!in_array($cat['value'], $categories)) {
echo '<li class="button"><a href="#" data-filter=".' . $slug . '">' . $cat['value'] . '</a></li>';
$categories[] = $cat['value'];
}
}
echo "</ul>";
echo '<div id="templates-container" >';
foreach ($extension_data as $this_extension => $data) {
if (substr($this_extension, 0, 4) == 'ext-') {
continue;
}
if (isset($data['info']['data_type']) && $data['info']['data_type'] == 'metabox') {
continue;
}
$cats = explode(',', $data['info']['category']);
foreach ($cats as $key => $cat) {
$cat = (is_array($cat)) ? implode(',',$cat) : $cat;
$cat = ($cat) ? trim($cat) : '';
$cat = str_replace(' ', '-', $cat);
$cats[$key] = trim(strtolower($cat));
}
$cat_slug = implode(' ', $cats);
$thumb = false;
if (file_exists(LANDINGPAGES_PATH . 'templates/' . $this_extension . "/thumbnail.png")) {
if ($this_extension == 'default') {
$thumbnail = get_template_directory() . "/screenshot.png";
if (file_exists($thumbnail)) {
$thumbnail = get_bloginfo('template_directory') . "/screenshot.png";
$thumb = true;
}
} else {
$thumbnail = LANDINGPAGES_URLPATH . 'templates/' . $this_extension . "/thumbnail.png";
$thumb = true;
}
}
if (file_exists(LANDINGPAGES_UPLOADS_PATH . $this_extension . "/thumbnail.png")) {
$thumbnail = LANDINGPAGES_UPLOADS_URLPATH . $this_extension . "/thumbnail.png";
$thumb = true;
}
if (file_exists(LANDINGPAGES_UPLOADS_PATH . $this_extension . "/thumbnail.jpg")) {
$thumbnail = LANDINGPAGES_UPLOADS_URLPATH . $this_extension . "/thumbnail.jpg";
$thumb = true;
}
if (!$thumb) {
$thumbnail = LANDINGPAGES_URLPATH . 'templates/default/thumbnail.png';
}
$demo_link = (isset($data['info']['demo'])) ? $data['info']['demo'] : '';
?>
<div id='template-item' class="<?php echo $cat_slug; ?> template-item-boxes">
<div id="template-box">
<div class="lp_tooltip_templates" title="<?php echo $data['info']['description']; ?>"></div>
<a class='lp_select_template' href='#' label='<?php echo $data['info']['label']; ?>'
id='<?php echo $this_extension; ?>'>
<img src="<?php echo $thumbnail; ?>" class='template-thumbnail'
alt="<?php echo $data['info']['label']; ?>" id='lp_<?php echo $this_extension; ?>'>
</a>
<p>
<div id="template-title"><?php echo $data['info']['label']; ?></div>
<a href='#' label='<?php echo $data['info']['label']; ?>' id='<?php echo $this_extension; ?>'
class='lp_select_template'><?php _e('Select', 'landing-pages'); ?></a> |
<a class='<?php echo $cat_slug;?>' target="_blank" href='<?php echo $demo_link;?>'
id='lp_preview_this_template'><?php _e('Preview', 'landing-pages'); ?></a>
</p>
</div>
</div>
<?php
}
echo '</div>';
echo "<div class='clear'></div>";
echo "</div>";
echo "<div style='display:none;' class='currently_selected'>" . __('This is Currently Selected', 'landing-pages') . "</a></div>";
}
public static function display_template_preview_metabox() {
global $post;
$template = Landing_Pages_Variations::get_current_template( $post->ID );
$permalink = Landing_Pages_Variations::get_variation_permalink( $post->ID );
$datetime = the_modified_date('YmjH',null,null,false);
$permalink = add_query_arg( array( 'dt' => $datetime , 'dont_save' => true ) , $permalink );
?>
<style type="text/css">
<?php
if ($template != 'default' ) {
echo '#postimagediv {display:none;}';
}
?>
background: transparent !important;
}
display: none !important;
}
padding: 0px !important;
border: none !important;
margin-top: -33px !important;
margin-bottom: -10px;
overflow:hidden;
}
vertical-align: top;
margin-top:33px !important;
}
margin-top: -30px;
}
</style>
<?php
if (isset($_GET['new-variation'])) {
return;
}
if( isset($_GET['inbound-editor']) && $_GET['inbound-editor'] !== true ) {
return;
}
echo "<iframe src='$permalink' id='zoomer'></iframe>";
}
public static function display_extended_metabox( $post , $args) {
$extension_data = Landing_Pages_Load_Extensions::get_extended_data();;
$key = $args['args']['key'];
if (!isset( $extension_data[$key]['settings'] ) ) {
return;
}
self::render_fields($key , $extension_data[$key]['settings'] , $post);
}
public static function display_additional_resources() {
global $post;
$variation_id = Landing_Pages_Variations::get_current_variation_id();
$salt = md5( $post->ID . AUTH_KEY );
?>
<div>
<table style='width:100%'>
<tr>
<td style='width:22%'>
<?php _e( 'Conversion Shortcode' , 'inbound-pro' ); ?>
</td>
<td>
<input type='text' style='width:95%;display:inline;' readonly='readonly' value="[landing-page-conversion id='<?php echo $post->ID; ?>' vid='<?php echo $variation_id; ?>']">
<div class="lp_tooltip" title="<?php _e( 'Instead of depending on Inbound Forms or tracked clicks for conversion tracking, enter this shortcode into your final destination page to manually increment this variation\'s conversion count' , 'landing-page' ); ?>" ><i class="fa fa-question-circle"></i></div>
</td>
</tr>
<tr>
<td>
<?php _e( 'Conversion Callback URL' , 'inbound-pro' ); ?>
</td>
<td>
<input type='text' style='width:95%;display:inline;' readonly='readonly' value="<?php echo add_query_arg( array( 'postback'=>'true' , 'event' => 'lp_conversion' , 'id' => $post->ID , 'vid' => $variation_id , 'salt' => $salt ) , site_url()) ?>">
<div class="lp_tooltip" title="<?php _e( 'If you would like to use a thrid party event to record a conversion you can use this cusomized callback URL.' , 'landing-page' ); ?>" ><i class="fa fa-question-circle"></i></div>
</td>
</tr>
</table>
</div>
<?php
}
public static function render_fields($key, $custom_fields, $post) {
echo "<input type='hidden' name='lp_{$key}_custom_fields_nonce' value='" . wp_create_nonce('lp-nonce') . "' />";
echo '<div class="form-table" id="inbound-meta">';
foreach ($custom_fields as $field) {
$field_id = Landing_Pages_Variations::prepare_input_id( $key . "-" . $field['id'] );
$field_name = $field['id'];
$label_class = $field['id'] . "-label";
$type_class = " inbound-" . $field['type'];
$type_class_row = " inbound-" . $field['type'] . "-row";
$type_class_option = " inbound-" . $field['type'] . "-option";
$option_class = (isset($field['class'])) ? $field['class'] : '';
$ink = get_option('lp-license-keys-' . $key);
$status = get_option('lp_license_status-' . $key);
$status_test = (isset($status) && $status != "") ? $status : 'inactive';
$meta = Landing_Pages_Variations::get_setting_value( $key . "-" . $field['id'] , $post->ID , null, $field['default'] );
if (isset($field['global']) && $field['global'] === true) {
$field_id = $field_name;
$meta = get_post_meta($post->ID, $field_name, true);
}
echo '<div class="' . $field['id'] . $type_class_row . ' div-' . $option_class . ' wp-call-to-action-option-row inbound-meta-box-row">';
if ($field['type'] != "description-block" && $field['type'] != "custom-css") {
echo '<div id="inbound-' . $field_id . '" data-actual="' . $field_id . '" class="inbound-meta-box-label wp-call-to-action-table-header ' . $label_class . $type_class . '"><label for="' . $field_id . '">' . $field['label'] . '</label></div>';
}
echo '<div class="wp-call-to-action-option-td inbound-meta-box-option ' . $type_class_option . '" data-field-type="' . $field['type'] . '">';
switch ($field['type']) {
case 'description-block':
echo '<div id="' . $field_id . '" class="description-block">' . $field['description'] . '</div>';
break;
case 'custom-css':
echo '<style type="text/css">' . $field['default'] . '</style>';
break;
case 'colorpicker':
if (!$meta) {
$meta = $field['default'];
}
$var_id = (isset($_GET['new_meta_key'])) ? "-" . $_GET['new_meta_key'] : '';
echo '<input type="text" class="jpicker" style="background-color:#' . $meta . '" name="' . $field_id . '" id="' . $field_id . '" value="' . $meta . '" size="5" /><span class="button-primary new-save-lp" data-field-type="text" id="' . $field_id . $var_id . '" style="margin-left:10px; display:none;">Update</span>
<div class="lp_tooltip tool_color" title="' . $field['description'] . '"></div>';
break;
case 'datepicker':
echo '<div class="jquery-date-picker inbound-datepicker" id="date-picking" data-field-type="text">
<span class="datepair" data-language="javascript">
Date: <input type="text" id="date-picker-' . $key . '" class="date start" /></span>
Time: <input id="time-picker-' . $key . '" type="text" class="time time-picker" />
<input type="hidden" name="' . $field_id . '" id="' . $field_id . '" value="' . $meta . '" class="new-date" value="" >
<p class="description">' . $field['description'] . '</p>
</div>';
break;
case 'text':
echo '<input type="text" name="' . $field_id . '" id="' . $field_id . '" value="' . $meta . '" size="30" />
<div class="lp_tooltip" title="' . $field['description'] . '"></div>';
break;
case 'number':
echo '<input type="number" class="' . $option_class . '" name="' . $field_id . '" id="' . $field_id . '" value="' . $meta . '" size="20" ' . (isset($field['min']) ? 'min="'.$field['min'].'"' : '' ) . ' ' . (isset($field['max']) ? 'max="'.$field['max'].'"' : '' ) . ' ' . (isset($field['step']) ? 'step="'.$field['step'].'"' : '' ) . '/>
<div class="lp_tooltip" title="' . $field['description'] . '"></div>';
break;
case 'textarea':
echo '<textarea name="' . $field_id . '" id="' . $field_id . '" cols="106" rows="6" style="width: 75%;">' . $meta . '</textarea>
<div class="lp_tooltip tool_textarea" title="' . $field['description'] . '"></div>';
break;
case 'wysiwyg':
echo "<div class='iframe-options iframe-options-" . $field_id . "' id='" . $field['id'] . "'>";
wp_editor($meta, $field_id, $settings = array('editor_class' => $field_name));
echo '<p class="description">' . $field['description'] . '</p></div>';
break;
case 'media':
echo '<label for="upload_image" data-field-type="text">';
echo '<input name="' . $field_id . '" id="' . $field_id . '" type="text" size="36" name="upload_image" value="' . $meta . '" />';
echo '<input data-field-id="' . $field_id . '" class="upload_image_button" id="uploader_' . $field_id . '" type="button" value="'.__('Upload Image' , 'inbound-pro' ) .'" />';
echo '<p class="description">' . $field['description'] . '</p>';
break;
case 'checkbox':
$i = 1;
echo "<table class='lp_check_box_table'>";
if (!isset($meta)) {
$meta = array();
} elseif (!is_array($meta)) {
$meta = array($meta);
}
foreach ($field['options'] as $value => $label) {
if ($i == 5 || $i == 1) {
echo "<tr>";
$i = 1;
}
echo '<td data-field-type="checkbox"><input type="checkbox" name="' . $field_id . '[]" id="' . $field_id . '" value="' . $value . '" ', in_array($value, $meta) ? ' checked="checked"' : '', '/>';
echo '<label for="' . $value . '"> ' . $label . '</label></td>';
if ($i == 4) {
echo "</tr>";
}
$i++;
}
echo "</table>";
echo '<div class="lp_tooltip tool_checkbox" title="' . $field['description'] . '"></div>';
break;
case 'radio':
foreach ($field['options'] as $value => $label) {
echo '<input type="radio" name="' . $field_id . '" id="' . $field_id . '" value="' . $value . '" ', $meta == $value ? ' checked="checked"' : '', '/>';
echo '<label for="' . $value . '"> ' . $label . '</label> ';
}
echo '<div class="lp_tooltip" title="' . $field['description'] . '"></div>';
break;
case 'dropdown':
echo '<select name="' . $field_id . '" id="' . $field_id . '" class="' . $field['id'] . '">';
foreach ($field['options'] as $value => $label) {
echo '<option', $meta == $value ? ' selected="selected"' : '', ' value="' . $value . '">' . $label . '</option>';
}
echo '</select><div class="lp_tooltip" title="' . $field['description'] . '"></div>';
break;
}
echo '</div></div>';
}
echo '</div>';
}
public static function ajax_get_template_metabox_html() {
global $wpdb;
$current_template = sanitize_text_field($_POST['selected_template']);
$post_id = intval($_POST['post_id']);
$post = get_post($post_id);
$args['args']['key'] = $current_template;
self::display_extended_metabox($post, $args);
die();
}
public static function save_landing_page( $landing_page_id ) {
global $post;
if ( !isset($post) || $post->post_type !='landing-page' || wp_is_post_revision( $landing_page_id ) ) {
return;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
return;
}
$variations = Landing_Pages_Variations::get_variations( $landing_page_id );
$variation_id = (isset($_REQUEST['lp-variation-id'])) ? intval($_REQUEST['lp-variation-id']) : '0';
$_SESSION['lp_ab_test_open_variation'] = $variation_id;
if (!in_array( $variation_id , $variations) ) {
$variations[] = $variation_id;
}
Landing_Pages_Variations::update_variations( $landing_page_id , $variations );
$ignore_list = array( 'acf' , 'post_status', 'post_type', 'tax_input', 'post_author', 'user_ID', 'post_ID', 'landing-page-myeditor', 'catslist', 'post_title', 'samplepermalinknonce', 'autosavenonce', 'action', 'autosave', 'mm', 'jj', 'aa', 'hh', 'mn', 'ss', '_wp_http_referer', 'lp-variation-id', '_wpnonce', 'originalaction', 'original_post_status', 'referredby', '_wp_original_http_referer', 'meta-box-order-nonce', 'closedpostboxesnonce', 'hidden_post_status', 'hidden_post_password', 'hidden_post_visibility', 'visibility', 'post_password', 'hidden_mm', 'cur_mm', 'hidden_jj', 'cur_jj', 'hidden_aa', 'cur_aa', 'hidden_hh', 'cur_hh', 'hidden_mn', 'cur_mn', 'original_publish', 'save', 'newlanding_page_category', 'newlanding_page_category_parent', '_ajax_nonce-add-landing_page_category', 'lp_lp_custom_fields_nonce', 'post_mime_type', 'ID', 'comment_status', 'ping_status');
foreach ($_REQUEST as $key => $value) {
if (in_array( $key , $ignore_list) ) {
continue;
}
if ( $variation_id > 0 && !strstr( $key, "-{$variation_id}")) {
$key = $key . '-' . $variation_id;
}
update_post_meta( $landing_page_id , $key , $value );
}
if(isset($_REQUEST['landing-page-myeditor'])) {
$conversion_area = wpautop($_REQUEST['landing-page-myeditor']);
$conversion_area_key = Landing_Pages_Variations::prepare_input_id( 'lp-conversion-area' , $variation_id );
update_post_meta( $landing_page_id , $conversion_area_key , $conversion_area);
}
}
public static function set_wpseo_priority() {
return 'low';
}
}
new Landing_Pages_Metaboxes;