Overview

Packages

  • ACF
  • Automation
    • Actions
    • Activation
    • LeadProfile
    • Menus
    • Queries
    • Rules
    • Triggers
  • CTA
    • Activation
    • AJAXListeners
    • Cloning
    • Core
    • Display
    • EditPage
    • Enqueues
    • GPLSettings
    • LeadsProfile
    • Loading
    • Menus
    • Notices
    • PlacementMetabox
    • PostType
    • Templates
    • Tracking
    • Variations
    • YOAST
  • InboundPro
    • Activation
    • AdminAJAX
    • AutoLoading
    • Cron
    • DataInterface
    • FieldMapping
    • Funnels
    • InboundNowAPI
    • Installer
    • LeadStatuses
    • Menus
    • Notifications
    • Ouath
    • Reports
    • Settings
    • Tracking
    • Translations
    • Updates
  • LandingPages
    • Activation
    • DataInterfaces
    • Management
    • Menus
    • NeedsAttention
    • Notices
    • Sidebars
    • Templates
    • Tracking
    • Variations
    • WelcomeScreen
    • Widgets
  • Leads
    • Activation
    • Akismet
    • BranchControl
    • BulkActions
    • Dashboard
    • Management
    • Notifications
    • Settings
    • Tracking
    • UserProfile
    • WPLogin
  • Mailer
    • Activation
    • Admin
    • ClickTracking
    • DataInterface
    • InboundForms
    • Leads
    • Management
    • Notifications
    • Scheduling
    • Sending
    • Settings
    • ShortcodesAndTokens
    • SparkPost
    • Templates
    • Unsubscribes
    • Variations
    • YoastSEO
  • None
  • Shared
    • APIs
    • CPT
    • DatabaseRoutines
    • DebugTricks
    • DoubleOptin
    • EventManagement
    • FieldMapping
    • InboundForms
    • LeadSorage
    • MarketingButton
    • Menus
    • Notifications
    • Shortcodes
    • ShortcodesAndTokens
    • StandAloneLicensing
    • Tracking
    • VisualEditor
  • xDepreciated

Classes

  • CTA_Activation
  • CTA_Activation_Update_Routines
  • CTA_Admin_Notices
  • CTA_Ajax_Listeners
  • CTA_Clone_Post
  • CTA_Conversion_Tracking
  • CTA_Dynamic_Widget
  • CTA_Enqueues
  • CTA_Load_Extensions
  • CTA_Menus
  • CTA_Metaboxes
  • CTA_Metaboxes_Global
  • CTA_Post_Type
  • CTA_Render
  • CTA_Settings
  • CTA_Static_Widget
  • CTA_Template_Manager
  • CTA_Template_Manager_List
  • CTA_Variations
  • CTA_WordPress_Leads
  • CTA_WordPress_SEO
  • Inbound_Ajax
  • Inbound_Akismet
  • Inbound_Analytics
  • Inbound_API
  • Inbound_API_Keys_Generation
  • Inbound_API_Keys_Table
  • Inbound_API_Wrapper
  • Inbound_Asset_Loader
  • Inbound_Automation_Action_Add_Remove_List
  • Inbound_Automation_Action_Add_Remove_Tag
  • Inbound_Automation_Action_Create_Lead
  • Inbound_Automation_Action_Create_User
  • Inbound_Automation_Action_Kill_Tasks
  • Inbound_Automation_Action_Relay_Data
  • Inbound_Automation_Action_Send_Email
  • Inbound_Automation_Action_Wait
  • Inbound_Automation_Activation
  • Inbound_Automation_Activation_Update_Routines
  • Inbound_Automation_Adminbar
  • Inbound_Automation_Lead_Profile
  • Inbound_Automation_Loader
  • Inbound_Automation_Plugin
  • Inbound_Automation_Post_Type
  • Inbound_Automation_Processing
  • Inbound_Automation_Query_Lead
  • Inbound_Automation_Query_User
  • Inbound_Automation_Trigger_inbound_double_optin_confirm
  • Inbound_Automation_Trigger_inbound_store_lead_post
  • Inbound_Automation_Trigger_inbound_track_link
  • Inbound_Automation_Trigger_Publish_Post
  • Inbound_Automation_Trigger_Save_Post_Deactivated
  • Inbound_Automation_Trigger_Set_Object_Terms
  • Inbound_Automation_Trigger_Update_Lead
  • Inbound_Automation_Trigger_User_Register
  • Inbound_Calls_To_Action_Plugin
  • Inbound_Confirm_Double_Optin
  • Inbound_Cron
  • Inbound_CTA_Quick_View
  • Inbound_Customizer
  • Inbound_Debug_Scripts
  • Inbound_Email_Meta
  • Inbound_Email_Preview
  • Inbound_Email_Template_Shortcodes
  • Inbound_Event_Report
  • Inbound_Events
  • Inbound_Events_Report
  • Inbound_Extension_Loads
  • Inbound_Forms
  • Inbound_Funnel_Reporting
  • Inbound_Impressions_Report
  • Inbound_Landing_Pages_Plugin
  • Inbound_Lead_Statuses
  • Inbound_Leads
  • Inbound_Leads_Custom_fields
  • Inbound_Leads_Plugin
  • Inbound_License
  • Inbound_List_Double_Optin
  • Inbound_Load_Shared
  • Inbound_Logging_Automation
  • Inbound_Login
  • Inbound_Mail_Daemon
  • Inbound_Mailer_ACF
  • Inbound_Mailer_Activation
  • Inbound_Mailer_Activation_Update_Routines
  • Inbound_Mailer_Ajax_Listeners
  • Inbound_Mailer_Clone_Post
  • Inbound_Mailer_Common_Settings
  • Inbound_Mailer_Customizer
  • Inbound_Mailer_Direct_Email_Leads
  • Inbound_Mailer_Enqueues
  • Inbound_Mailer_Forms_Integration
  • Inbound_Mailer_Load_Templates
  • Inbound_Mailer_Menus
  • Inbound_Mailer_Metaboxes
  • Inbound_Mailer_Notifications
  • Inbound_Mailer_Plugin
  • Inbound_Mailer_Post_Type
  • Inbound_Mailer_Scheduling
  • Inbound_Mailer_Settings
  • Inbound_Mailer_SparkPost
  • Inbound_Mailer_Stats_Report
  • Inbound_Mailer_Template_Manager
  • Inbound_Mailer_Template_Manager_List
  • Inbound_Mailer_Tokens
  • Inbound_Mailer_Tracking
  • Inbound_Mailer_Unsubscribe
  • Inbound_Mailer_Variations
  • Inbound_Mailer_WordPress_SEO
  • Inbound_Maintenance_Lists
  • Inbound_Marketing_Button
  • Inbound_Menus_Admin
  • Inbound_Menus_Adminbar
  • Inbound_Metaboxes_Automation
  • Inbound_Metaboxes_Leads
  • Inbound_Notifications
  • Inbound_Now_Store
  • Inbound_Options_API
  • Inbound_Pro_Activation
  • Inbound_Pro_Admin_Ajax_Listeners
  • Inbound_Pro_Automatic_Updates
  • Inbound_Pro_Downloads
  • Inbound_Pro_Notifications
  • Inbound_Pro_Oauth_Engine
  • Inbound_Pro_Plugin
  • Inbound_Pro_Settings
  • Inbound_Quick_View
  • Inbound_Reporting_Templates
  • Inbound_Search_And_Comment_Report
  • Inbound_Shared_ACF_BootStrap
  • Inbound_Shortcodes
  • Inbound_Shortcodes_Cookies
  • Inbound_Shortcodes_Fields
  • Inbound_SparkPost
  • Inbound_SparkPost_Stats
  • Inbound_Template_Utils
  • Inbound_Templating_Engine
  • Inbound_Tracking
  • Inbound_Translation_Updater
  • Inbound_Updater
  • Inbound_Upgrade_For_More_Reports
  • Inbound_Upgrade_Routines
  • Inbound_Visitor_Event_Report
  • Inbound_Visitor_Impressions_Report
  • Inbound_Visitors_Report
  • INBOUNDNOW_EXTEND
  • Landing_Pages_ACF
  • Landing_Pages_Activation
  • Landing_Pages_Activation_Update_Routines
  • Landing_Pages_Admin_Menus
  • Landing_Pages_Admin_Notices
  • Landing_Pages_Install
  • Landing_Pages_Load_Extensions
  • Landing_Pages_Meta
  • Landing_Pages_Metaboxes
  • Landing_Pages_Post_Type
  • Landing_Pages_Row_Actions
  • Landing_Pages_Settings
  • Landing_Pages_Sidebars
  • Landing_Pages_Split_Testing_Stats
  • Landing_Pages_Template_Management
  • Landing_Pages_Template_Switcher
  • Landing_Pages_Templates_List_Table
  • Landing_Pages_Variations
  • LandingPages_Welcome
  • Leads_Activation
  • Leads_Activation_Update_Routines
  • Leads_Admin_Notices
  • Leads_Batch_Processor
  • Leads_Branching
  • Leads_Dashboard
  • Leads_Field_Map
  • Leads_Manager
  • Leads_Post_Type
  • Leads_Settings
  • Leads_Tracking
  • Leads_User_Profile
  • LeadStorage
  • LP_EXTENSION_LICENSENING
  • LP_EXTENSION_UPDATER
  • LP_Variation_Rotation
  • LP_Widget_Conversion_Area

Functions

  • cta_check_active
  • cta_example_template_function
  • cta_load_dynamic_widget
  • CTA_Load_Extensions
  • cta_load_static_widget
  • CTA_Render
  • inbound_add_conversion_to_lead
  • inbound_automation_check_active
  • inbound_automation_load_definitions
  • inbound_automation_metaboxes
  • inbound_automation_processing
  • inbound_color
  • inbound_color_scheme
  • inbound_confirm_email_service_provider
  • inbound_email_kill_ie8
  • inbound_email_load_templates
  • inbound_form_add_lead_list
  • inbound_form_auto_publish
  • inbound_form_delete_transient
  • inbound_form_get_data
  • inbound_form_save
  • inbound_forms_change_columns
  • inbound_forms_cpt
  • inbound_forms_custom_columns
  • inbound_forms_default_content
  • inbound_get_form_names
  • inbound_get_parent_directory
  • inbound_Hex_2_RGB
  • inbound_inbound_email_example_template_function
  • inbound_load_lead_manager
  • inbound_load_token_engine
  • inbound_mailer_acf_integration
  • Inbound_Mailer_Common_Settings
  • Inbound_Mailer_Load_Templates
  • inbound_qtrans_disable
  • inbound_record_log
  • inbound_register_form_role_capabilities
  • inbound_shortcode_alert
  • inbound_shortcode_callout
  • inbound_shortcode_columns
  • inbound_shortcode_content_box
  • inbound_shortcode_divider
  • inbound_shortcode_empty_paragraph_fix
  • inbound_shortcode_four_fifth_columns
  • inbound_shortcode_full_columns
  • inbound_shortcode_gmap
  • inbound_shortcode_icon
  • inbound_shortcode_intro
  • inbound_shortcode_landing_pages
  • inbound_shortcode_leadp
  • inbound_shortcode_list_icons
  • inbound_shortcode_one_fifth_columns
  • inbound_shortcode_one_fourth_columns
  • inbound_shortcode_one_half_columns
  • inbound_shortcode_one_third_columns
  • inbound_shortcode_portfolio
  • inbound_shortcode_pricing
  • inbound_shortcode_profile
  • inbound_shortcode_social_links
  • inbound_shortcode_tabs
  • inbound_shortcode_teaser
  • inbound_shortcode_testimonial
  • inbound_shortcode_three_fifth_columns
  • inbound_shortcode_three_fourth_columns
  • inbound_shortcode_two_fifth_columns
  • inbound_shortcode_two_third_columns
  • inbound_shortcode_video
  • inbound_store_lead
  • inbound_template_brightness
  • inbound_template_color
  • Inbound_Templating_Engine
  • inbound_travis_check
  • inboundnow_add_master_license
  • json_encode_fallback
  • landingpage_fix_known_wp_title_isses
  • landingpages_is_active
  • load_CTA_Settings
  • load_CTA_Template_Manager
  • load_Inbound_API_Keys_Generation
  • load_Inbound_Lead_Statuses
  • load_Inbound_Leads_Custom_fields
  • load_inbound_mail_daemon
  • load_Inbound_Mailer_Settings
  • load_Inbound_Mailer_Template_Manager
  • load_Inbound_Pro_Downloads
  • lp_ab_testing_get_current_variation_id
  • lp_add_option
  • lp_body_class
  • lp_check_active
  • lp_content_area
  • lp_conversion_area
  • lp_discover_important_wrappers
  • lp_footer
  • lp_generate_drowndown
  • lp_get_parent_directory
  • lp_get_value
  • lp_global_config
  • lp_head
  • lp_in_admin_header
  • lp_init
  • lp_list_feature
  • lp_load_widgets
  • lp_main_headline
  • lp_manage_templates
  • lp_move_template_files
  • lp_rebuild_attributes
  • lp_templates_upload
  • mailer_check_active
  • wp_cta_check_active
  • wp_cta_kill_ie8
  • wp_cta_load_calls_to_action
  • wp_leads_get_page_final_id
  • wpl_url_to_postid
  • wpleads_add_lead_to_list
  • wpleads_check_active
  • wpleads_get_lead_lists_as_array
  • Overview
  • Package
  • Class
   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: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290: 1291: 1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 
<?php

/**
 * Class for managing/editing automation rules
 * @package     Automation
 * @subpackage  Rules
 */

class Inbound_Metaboxes_Automation {


    static $post_type;

    static $rule_trigger;
    static $rule_trigger_evaluate;
    static $rule_trigger_filters;
    static $rule_action_blocks;

    static $Inbound_Automation;
    static $rule; /* rule dataset */
    static $triggers;
    static $argument_filters;
    static $actions;
    static $db_lookup_filters;

    public function __construct() {
        self::$post_type = 'automation';
        self::load_hooks();
    }

    public static function load_hooks() {
        /* Setup Variables */
        add_action('posts_selection', array(__CLASS__, 'load_rule'));

        /* add logs page */
        add_action( 'admin_menu', array( __CLASS__ , 'add_logs_page_support' ) );

        /* Add Metaboxes */
        add_action('add_meta_boxes', array(__CLASS__, 'define_metaboxes'));

        /* Replace Default Title Text */
        add_filter('enter_title_here', array(__CLASS__, 'change_title_text'), 10, 2);

        /* Add Save Actions */
        add_action('save_post', array(__CLASS__, 'save_automation'));

        /* Enqueue JS */
        add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_admin_scripts'));
        add_action('admin_print_footer_scripts', array(__CLASS__, 'print_admin_scripts'));

        /* Setup Ajax Listeners - Get Trigger Argument Filters*/
        add_action('wp_ajax_automation_get_trigger_arguments', array(__CLASS__, 'ajax_load_trigger_arguments'));

        /* Setup Ajax Listeners - Get Action DB Lookup Filters*/
        add_action('wp_ajax_automation_get_db_lookup_filters', array(__CLASS__, 'ajax_load_db_lookup_filters'));

        /* Setup Ajax Listeners - Get Actions */
        add_action('wp_ajax_automation_get_actions', array(__CLASS__, 'ajax_load_action_definitions'));

        /* Setup Ajax Listeners - Build Trigger Filter Settings*/
        add_action('wp_ajax_automation_build_trigger_filter', array(__CLASS__, 'ajax_build_trigger_filter'));

        /* Setup Ajax Listeners - Build DB Lookup Filter Settings*/
        add_action('wp_ajax_automation_build_db_lookup_filter', array(__CLASS__, 'ajax_build_db_lookup_filter'));

        /* Setup Ajax Listeners - Build Action Settings*/
        add_action('wp_ajax_automation_build_action', array(__CLASS__, 'ajax_build_action'));

        /* Setup Ajax Listeners - Build Action Block*/
        add_action('wp_ajax_automation_build_action_block', array(__CLASS__, 'ajax_build_action_block'));

        /* Setup Ajax Listeners - Clear logs */
        add_action('wp_ajax_automation_clear_logs', array(__CLASS__, 'ajax_clear_logs'));

        /* set default screen column to 1 */
        add_filter( 'get_user_option_screen_layout_automation', array (__CLASS__, 'screen_layout_columns' ) );


    }

    /**
     *    Load automation definitions
     */
    public static function load_definitions() {

        /* prevent repeat calls */
        if (isset(self::$Inbound_Automation)) {
            return;
        }


        self::$Inbound_Automation = inbound_automation_load_definitions();
        self::$triggers = self::$Inbound_Automation->triggers;
        self::$argument_filters = self::$Inbound_Automation->argument_filters;
        self::$actions = self::$Inbound_Automation->actions;
        self::$db_lookup_filters = self::$Inbound_Automation->db_lookup_filters;

    }

    /**
     *    Load rule settings iinto static variables
     */
    public static function load_rule() {
        global $post;

        if (!isset($post) || $post->post_type != self::$post_type || !isset($_GET['post'])) {
            return;
        }

        self::$rule = get_post_meta($post->ID, 'inbound_rule', true);

        self::$rule_trigger = (isset(self::$rule['trigger'])) ? self::$rule['trigger'] : '';
        self::$rule_trigger_evaluate = (isset(self::$rule['trigger_filters_evaluate'])) ? self::$rule['trigger_filters_evaluate'] : '';
        self::$rule_trigger_filters = (isset(self::$rule['trigger_filters'])) ? self::$rule['trigger_filters'] : array();
        self::$rule_action_blocks = (isset(self::$rule['action_blocks'])) ? self::$rule['action_blocks'] : array(1 =>array());

    }

    public static function define_metaboxes() {
        global $post;

        if ($post->post_type != self::$post_type) {
            return;
        }

        /* Rule Settings */
        add_meta_box(
            'inbound_automation_settings', // $id
            __('Trigger', 'inbound-pro'),
            array(__CLASS__, 'display_container'), // $callback
            self::$post_type,
            'normal',
            'high'
        );


        /* Load Action Blocks If Available */
        if (!isset(self::$rule_action_blocks)) {
            self::$rule_action_blocks = array( 1 =>array() );
        }

        foreach (self::$rule_action_blocks as $block_id => $block) {

            /* Rule Settings */
            add_meta_box(
                'inbound_automation_actions_' . $block_id,
                __('Actions', 'inbound-pro'),
                array( __CLASS__ , 'print_actions'),
                self::$post_type,
                'normal',
                'high',
                array(
                    'block_id' => $block_id,
                    'block' => $block
                )
            );
        }

        /* Logs */
        add_meta_box(
            'inbound_automation_logs', // $id
            __('Logs', 'inbound-pro'),
            array(__CLASS__, 'print_logs_container'), // $callback
            self::$post_type,
            'normal',
            'low'
        );
    }

    /**
     *
     */
    public static function display_container() {
        global $post;

        self::load_definitions();
        self::print_trigger_container();
        //self::print_actions_container();
        //self::print_logs_container();

    }

    /**
     * Add page support for logs
     */
    public static function add_logs_page_support() {

        add_submenu_page(
            'automation',
            __('Logs','inbound-pro'),
            __('Logs','inbound-pro'),
            'manage_options',
            'inbound_rule_logs',
            array( __CLASS__  , 'print_logs')
        );
    }

    public static function print_trigger_container() {

        ?>
        <div class='nav-container nav-reveal trigger-container' id='trigger-container'>
            <table class='table-trigger-container'>
                <tr class='tr-trigger-select'>
                    <td>
                        <h2 class='trigger-section-header'><?php _e('Define Trigger','mailer'); ?></h2>
                        <select class='trigger-dropdown form-control' id='trigger-dropdown' name='trigger'>
                            <?php
                            echo '<option value="-1" class="">Select Trigger</option>';
                            foreach (self::$triggers as $hook => $trigger) {
                                echo '<option
                                        value="' . $hook . '"
                                        class="' . (isset($trigger['icon_class']) ? $trigger['icon_class'] : '') . '"
                                        ' . (isset(self::$rule_trigger) && self::$rule_trigger == $hook ? 'selected="selected"' : '') . '
                                        >' . $trigger['label'] . '</option>';
                            }

                            ?>
                        </select>
                    </td>
                </tr>
                <tr class="tr-filter-select">
                    <td class='td-filter-add-dropdown' id='argument-filters-container'>
                        <h2 class='trigger-section-header' ><?php _e('Define Conditions' , 'mailer' ); ?></h2>

                        <div
                            class='trigger-filter-evaluate <?php if (!isset(self::$rule_trigger_filters) || count(self::$rule_trigger_filters) < 1) {
                                echo 'nav-hide';
                            } ?>'>
                            <div class="btn-group btn-group-evaluate" data-toggle="buttons">
                                <label
                                    class="btn btn-default  <?php if (!self::$rule_trigger_evaluate || self::$rule_trigger_evaluate == 'match-all') {
                                        echo 'active';
                                    } ?>">
                                    <input type='radio' name='trigger_filters_evaluate'
                                           value='match-all' <?php if (!self::$rule_trigger_evaluate || self::$rule_trigger_evaluate == 'match-all') {
                                        echo 'checked="checked"';
                                    } ?>> Match All
                                </label>
                                <label
                                    class="btn btn-default  <?php if (self::$rule_trigger_evaluate == 'match-any') {
                                        echo 'active';
                                    } ?>">
                                    <input type='radio' name='trigger_filters_evaluate'
                                           value='match-any' <?php if (self::$rule_trigger_evaluate == 'match-any') {
                                        echo 'checked="checked"';
                                    } ?>> Match Any
                                </label>
                                <label
                                    class="btn btn-default  <?php if (self::$rule_trigger_evaluate == 'match-none') {
                                        echo 'active';
                                    } ?>">
                                    <input type='radio' name='trigger_filters_evaluate'
                                           value='match-none' <?php if (self::$rule_trigger_evaluate == 'match-none') {
                                        echo 'checked="checked"';
                                    } ?>> Match None
                                </label>
                            </div>
                            <div class="btn-group add-filter">
                                <button type="button" class="btn btn-warning dropdown-toggle ladda-button"
                                        data-style="expand-right" data-toggle="dropdown"
                                        id='add-trigger-filter-button'>
                                    <?php _e('Add Filter', 'mailer'); ?><span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-left trigger-filters" role="menu">
                                    <li><a><?php _e(' Select a filter...', 'mailer'); ?></a></li>
                                </ul>
                            </div>


                            <?php
                            /* Load Trigger Filters if available */
                            if (isset(self::$rule_trigger_filters)) {
                                foreach (self::$rule_trigger_filters as $child_id => $filter) {

                                    $args = array('trigger_id' => self::$rule_trigger, 'trigger_filter_id' => $filter['trigger_filter_id'], 'child_id' => $child_id, 'defaults' => $filter);

                                    $html = self::ajax_build_trigger_filter($args);
                                    echo $html;

                                }

                            }
                            ?>

                    </td>
                </tr>
            </table>
        </div>
        <?php
    }

    /**
     * Renders log section that shows latest rule processing log data
     */
    public static function print_logs_container() {
        global $inbound_automation_logs, $post;
        ?>
        <iframe
            src="<?php echo admin_url('admin.php?page=inbound_rule_logs&rule_id='.$post->ID); ?>"
            frameborder="0" style="height:100vh;width:100%;"  width="100%">
        </iframe>
        <?php
    }

    /**
     * Renders log section that shows latest rule processing log data
     */
    public static function print_logs() {
        global $inbound_automation_logs, $post;

        $post = get_post($_GET['rule_id']);
        $logs = array_reverse($inbound_automation_logs->get_logs($post->ID), true);

        ?>
        <style>
            html.wp-toolbar {
                background:#fff;
                padding-top:20px;
            }
            header,head,body {
                background:#fff;
            }
            .tr-log-entry-content {
                display: none;
            }

            #th-log-id, #th-log-expand {
                width: 50px;
            }

            .tablesorter {
                table-layout: fixed;
                background: #fff;
                max-width: 100%;
                border-spacing: 0;
                width: 100%;
                margin: 10px 0;
                border: 1px solid #ddd;
                border-collapse: separate;
                *border-collapse: collapsed;
                -webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.10);
                -moz-box-shadow: 0 0 4px rgba(0, 0, 0, 0.10);
                box-shadow: 0 0 4px rgba(0, 0, 0, 0.10);
            }

            .tablesorter th, .tablesorter td {
                padding: 8px;
                line-height: 18px;
                text-align: left;
                border-top: 1px solid #ddd;
                word-wrap: break-word;
            }

            .tablesorter th {
                background: #eee;
                background: -webkit-gradient(linear, left top, left bottom, from(#f6f6f6), to(#eee));
                background: -moz-linear-gradient(top, #f6f6f6, #eee);
                text-shadow: 0 1px 0 #fff;
                font-weight: bold;
                vertical-align: bottom;
            }

            .tablesorter td {
                vertical-align: top;
            }

            .tablesorter thead:first-child tr th,
            .tablesorter thead:first-child tr td {
                border-top: 0;
            }

            .tablesorter tbody + tbody {
                border-top: 2px solid #ddd;
            }

            .tablesorter th + th,
            .tablesorter td + td,
            .tablesorter th + td,
            .tablesorter td + th {
                border-left: 1px solid #ddd;
            }

            .tablesorter thead:first-child tr:first-child th,
            .tablesorter tbody:first-child tr:first-child th,
            .tablesorter tbody:first-child tr:first-child td {
                border-top: 0;
            }

            #wpadminbar, #adminmenumain {
                display:none;
            }

            #wpcontent {
                margin-left:0px !important;
            }
        </style>
        <div class='nav-container logs-container' id='logs-container'>
            <div class='clear-logs-container'>
                <span class='button button-secondary' id='clear-logs' data-rule-id='<?php echo $post->ID; ?>'>
                    <?php _e( 'Clear logs' , 'inbound-pro' ); ?>
                </span>
                <span class='button button-secondary' id='refresh-logs' data-rule-id='<?php echo $post->ID; ?>'>
                    <?php _e( 'Refresh logs' , 'inbound-pro' ); ?>
                </span>
            </div>
            <table class='tablesorter'>
                <tr>
                    <th class=" sort-header" id='th-log-id'><?php _e('Log ID', 'inbound-pro'); ?></th>
                    <th class=" sort-header" id='th-log-title'><?php _e('Log Title', 'inbound-pro'); ?></th>
                    <th class=" sort-header" id='th-log-date'><?php _e('Log Date', 'inbound-pro'); ?></th>
                    <th class=" sort-header" id='th-log-date'><?php _e('Task ID', 'inbound-pro'); ?></th>
                    <th class=" sort-header" id='th-log-date'><?php _e('Log Type', 'inbound-pro'); ?></th>
                    <th class=" sort-header" id='th-log-expand'><?php _e('Expand', 'inbound-pro'); ?></th>
                </tr>
                <?php
                $i = 0;
                foreach ($logs as $key => $log) {

                    if ($i > 50) {
                        break;
                    }
                    echo '<tr class="tr-log-entry"  data-id="' . $key . '">';
                    echo '  <td class="td-log log-title">' . $key . '</td>';
                    echo '  <td class="td-log log-title">' . $log['log_title'] . '</td>';
                    echo '  <td class="td-log log-datetime">' . $log['log_datetime'] . '</td>';
                    echo '  <td class="td-log log-datetime">' . $log['job_id'] . '</td>';
                    echo '  <td class="td-log log-datetime">' . $log['log_type'] . '</td>';
                    echo '  <td class="td-log log-datetime"><a href="javascript:void(0);" class="toggle-log-content" data-id="' . $key . '">+/-</a></td>';
                    echo '</tr>';
                    echo '<tr class="tr-log-entry-content" id="log-content-' . $key . '" data-id="' . $key . '">';
                    echo '  <td colspan=6 class="td-log-entry-content"data-id="' . $key . '" >';
                    echo stripslashes(base64_decode($log['log_content']));
                    echo '  </td>';
                    echo '</td>';
                    echo '</tr>';
                    $i++;
                }

                ?>
            </table>
        </div>
        <?php
    }


    /**
     * Renders action blocks already saved to this rule
     * @param OBJECT
     * @param ARRAY
     */
    public static function print_actions($post, $args) {
        global $post;

        $html = self::ajax_build_action_block($args['args']['block_id'], $action_priority = null, $args['args']['block']);
        echo $html;
    }


    /**
     * Constructs the rule data set and saves it in post meta
     * @param INT $post_id
     */
    public static function save_automation($post_id) {
        global $post;

        if (!isset($post)) {
            return;
        }

        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
            return;
        }

        if (!current_user_can('edit_post', $post_id)) {
            return;
        }

        if ($post->post_type != self::$post_type) {
            return;
        }

        /* load definitions */
        self::load_definitions();

        $rule = array();

        /* Save trigger */
        $rule['trigger'] = $_POST['trigger'];

        /* Save Trigger Filters */
        if (isset ($_POST['trigger_filter_value'])) {

            $filters = array();

            foreach ($_POST['trigger_filter_key'] as $id => $value) {

                (isset($_POST['trigger_filter_id'][$id])) ? $filters[$id]['trigger_filter_id'] = $_POST['trigger_filter_id'][$id] : $filters[$id]['trigger_filter_id'] = null;
                (isset($_POST['trigger_filter_key'][$id])) ? $filters[$id]['trigger_filter_key'] = $_POST['trigger_filter_key'][$id] : $filters[$id]['key'] = null;
                (isset($_POST['trigger_filter_compare'][$id])) ? $filters[$id]['trigger_filter_compare'] = $_POST['trigger_filter_compare'][$id] : $filters[$id]['trigger_filter_compare'] = null;
                (isset($_POST['trigger_filter_value'][$id])) ? $filters[$id]['trigger_filter_value'] = $_POST['trigger_filter_value'][$id] : $filters[$id]['value'] = null;

            }

            $rule['trigger_filters'] = $filters;

        }

        /* Save Trigger Filter Evaulation Nature */
        if (isset ($_POST['trigger_filters_evaluate'])) {
            $rule['trigger_filters_evaluate'] = $_POST['trigger_filters_evaluate'];
        }


        /* Save Action Blocks */
        if (isset ($_POST['action_block_id'])) {

            $action_blocks = array();

            foreach ($_POST['action_block_id'] as $block_id) {

                /* get action block filter evaluation nature */
                $action_blocks[$block_id]['action_block_filters_evaluate'] = $_POST['action_block_filters_evaluate'][$block_id];

                /* Get Action Filter Conditions for this block if they exist */
                $filters = array();

                if (isset($_POST['action_filter_value'][$block_id])) {

                    foreach ($_POST['action_filter_value'][$block_id] as $id => $filter_value) {

                        (isset($_POST['action_filter_id'][$block_id][$id])) ? $filters[$id]['action_filter_id'] = $_POST['action_filter_id'][$block_id][$id] : $filters[$id]['action_filter_id'] = null;
                        (isset($_POST['action_filter_key'][$block_id][$id])) ? $filters[$id]['action_filter_key'] = $_POST['action_filter_key'][$block_id][$id] : $filters[$id]['key'] = null;
                        (isset($_POST['action_filter_compare'][$block_id][$id])) ? $filters[$id]['action_filter_compare'] = $_POST['action_filter_compare'][$block_id][$id] : $filters[$id]['action_filter_compare'] = null;
                        (isset($_POST['action_filter_value'][$block_id][$id])) ? $filters[$id]['action_filter_value'] = $_POST['action_filter_value'][$block_id][$id] : $filters[$id]['value'] = null;

                    }

                }

                /* Add Filters to $action_blocks */
                $action_blocks[$block_id]['filters'] = $filters;

                /* Get Then Actions For This Block If They Exist */
                $actions = array();
                if (isset($_POST['action_name'][$block_id]['then'])) {

                    foreach ($_POST['action_name'][$block_id]['then'] as $child_id => $action_name) {

                        $this_action = self::$actions[$action_name];

                        if (!isset($this_action['settings'])) {
                            continue;
                        }

                        $actions[$child_id]['action_name'] = $action_name;
                        $actions[$child_id]['action_class_name'] = $this_action['class_name'];

                        foreach ($this_action['settings'] as $setting) {

                            if (isset($_POST[$setting['id']][$block_id]['then'][$child_id])) {
                                $actions[$child_id][$setting['id']] = $_POST[$setting['id']][$block_id]['then'][$child_id];
                            }

                        }

                    }

                }

                /* Add Actions to Action Block */
                $action_blocks[$block_id]['actions']['then'] = $actions;

                /* Get Else Actions For This Block If They Exist */
                $actions = array();
                if (isset($_POST['action_name'][$block_id]['else'])) {

                    /* Get Action Definitions */
                    foreach ($_POST['action_name'][$block_id]['else'] as $child_id => $action_name) {

                        $this_action = self::$actions[$action_name];

                        if (!isset($this_action['settings'])) {
                            continue;
                        }

                        $actions[$child_id]['action_name'] = $action_name;
                        $actions[$child_id]['action_class_name'] = $this_action['class_name'];

                        foreach ($this_action['settings'] as $setting) {

                            if (isset($_POST[$setting['id']][$block_id]['else'][$child_id])) {
                                $actions[$child_id][$setting['id']] = $_POST[$setting['id']][$block_id]['else'][$child_id];
                            }

                        }
                    }
                }

                /* Add Actions to Action Block */
                if ($actions) {
                    $action_blocks[$block_id]['actions']['else'] = $actions;
                }
            }


            /* Save Actions */
            $rule['action_blocks'] = $action_blocks;

        }

        /* load and merge old rules */
        $old_rule = get_post_meta($post_id, 'inbound_rule', true);
        $rule['defer'] = ( isset( $old_rule['defer']) ) ? $old_rule['defer'] : 'on';
        $rule['status'] = ( isset( $old_rule['status']) ) ? $old_rule['status'] : 'on';

        /* Save rule into post meta */
        update_post_meta($post_id, 'inbound_rule', $rule);


    }


    public static function change_title_text($text, $post) {
        if ($post->post_type == self::$post_type) {
            return __('Enter Rule Name Here', 'inbound-pro');
        } else {
            return $text;
        }
    }


    /* Enqueue Admin Scripts */
    public static function enqueue_admin_scripts($hook) {
        global $post;


        /* if logs iframe load js */
        if ($hook == 'admin_page_inbound_rule_logs') {
            $post = get_post( $_GET['rule_id']);
        }

        if (!isset($post) || $post->post_type != self::$post_type) {
            return;
        }


        if ($hook == 'post-new.php' || $hook == 'post.php' || $hook == 'admin_page_inbound_rule_logs') {

            /* disable heartbeat */
            wp_deregister_script('heartbeat');

            /* disable compression test */
            wp_deregister_script('wp-compression-test');

            wp_enqueue_script('jquery-ui-core');

            //wp_enqueue_script('jquery-ui-sortable');
            wp_enqueue_script('jquery-effects-core');
            wp_enqueue_script('jquery-effects-highlight');

            wp_enqueue_style('inbound_automation_admin_css', INBOUND_AUTOMATION_URLPATH . 'assets/css/admin/admin.post-edit.css');
            wp_enqueue_style('automation-admin-jquery-ui-css', INBOUND_AUTOMATION_URLPATH . 'assets/css/jquery-ui.css');

            /* load BootStrap */
            wp_register_script('bootstrap', INBOUNDNOW_SHARED_URLPATH . 'assets/includes/BootStrap/js/bootstrap.min.js');
            wp_enqueue_script('bootstrap');

            /* BootStrap CSS */
            wp_register_style('bootstrap', INBOUNDNOW_SHARED_URLPATH . 'assets/includes/BootStrap/css/bootstrap.css');
            wp_enqueue_style('bootstrap');

            /* Spin.min.js - For button loading effect */
            wp_register_script('spin-js', INBOUND_AUTOMATION_URLPATH . 'assets/libraries/Ladda/spin.min.js');
            wp_enqueue_script('spin-js');

            /* Ladda.min.js - For button loading effect*/
            wp_register_script('ladda-js', INBOUND_AUTOMATION_URLPATH . 'assets/libraries/Ladda/ladda.min.js');
            wp_enqueue_script('ladda-js');

            /* Load ladda css */
            wp_register_style('ladda-css', INBOUND_AUTOMATION_URLPATH . 'assets/libraries/Ladda/ladda-themeless.min.css');
            wp_enqueue_style('ladda-css');

            /* Load FontAwesome */
            wp_register_style('fontawesome', INBOUNDNOW_SHARED_URLPATH . 'assets/fonts/fontawesome/css/font-awesome.min.css');
            wp_enqueue_style('fontawesome');

            /* Load Main JS File */
            wp_register_script('inbound-rules-js', INBOUND_AUTOMATION_URLPATH . 'assets/js/admin.rule-setup.js');
            wp_enqueue_script('inbound-rules-js');
            wp_localize_script('inbound-rules-js' , 'inbound_rules' , array('hook' => $hook ));

            /* Enqueue Select2 */
            wp_enqueue_script('selectjs', INBOUNDNOW_SHARED_URLPATH . 'assets/includes/Select2/select2.min.js', array() , null , false );
            wp_enqueue_style('selectjs', INBOUNDNOW_SHARED_URLPATH . 'assets/includes/Select2/select2.css');

            /* load Sweet Alert */
            wp_enqueue_script('sweetalert', INBOUND_AUTOMATION_URLPATH . 'assets/libraries/SweetAlert/dist/sweetalert.min.js');
            wp_enqueue_style('sweetalert', INBOUND_AUTOMATION_URLPATH . 'assets/libraries/SweetAlert/dist/sweetalert.css');

        }
    }

    /**
     *    Print Admin Scripts
     */
    public static function print_admin_scripts() {
        global $post;

        if (!isset($post) || $post->post_type != self::$post_type) {
            return;
        }

        ?>
        <script>
            jQuery(function () {
                jQuery('[data-toggle="tooltip"]').tooltip()
            });
        </script>
        <?php

    }




    /**
     * Renders or Returns Action Block HTML - This method doubles as an inline call or an ajax call
     *
     * @param action_block_type STRING
     * @param action_block_id STRING Which Action Block Placement Spot Is Next In Line
     * @param action_priority STRING Which Action Queue placement spot is next in line within the action block
     * @param block ARRAY data for generating historic action blocks
     *
     */
    public static function ajax_build_action_block($action_block_id = null, $action_priority = null, $block = null) {

        /* loads automation definitions */
        self::load_definitions();

        (isset($_REQUEST['action_block_id'])) ? $action_block_id = intval($_REQUEST['action_block_id']) : $action_block_id;
        (isset($_REQUEST['action_block_priority'])) ? $action_block_id = intval($_REQUEST['action_block_priority']) : $action_block_id;

        $html = '';
        $html .= '<div class="action-block-wrapper" data-action-block="' . $action_block_id . '">';
        //$html .= '<div class="action-block-delete"><button class="btn btn-default btn-small delete-action-block" title="'.__('Delete Action Block' , 'inbound-pro' ) .'" data-action-block="'. $action_block_id .'"><i class="fa fa-times"></i></button></div>';
        $html .= "<div class='action-block' data-block-id='" . $action_block_id . "' >";
        $html .= "<div class='action-block-div' data-action-block-priority='" . $action_priority . "'>";
        $html .= "      <input type='hidden' name='action_block_id[" . $action_block_id . "]' value='" . $action_block_id . "'>";

        /* Action Filters */
        $html .= "      <div id='action-block-filters' class='action-block-conditions'>";
        $html .= "            <h2 class='action-block-section-header'>" . __('Additional conditions', 'inbound-pro') . "</h2>";

        /* Add Action Filters */
        $html .= '            <div class="dropdown-add-filters" data-block-id="' . $action_block_id . '">';
        $html .= '                <span class="dropdown-toggle add-action-filters" data-block-id="' . $action_block_id . '" data-action-type="then" type="button"  data-toggle="dropdown">';
        $html .= '                   <i class="fa fa-plus-circle"></i>';
        $html .= '                </span>';
        $html .= '                <ul class="dropdown-menu dropdown-menu-left action-filter-options" role="menu" aria-labelledby="menu1" >';
        $html .= '               </ul>';
        $html .= '            </div>';

        /* Add Action Filter Evaluation Nature */
        $block['action_block_filters_evaluate'] = (isset($block['action_block_filters_evaluate'])) ? $block['action_block_filters_evaluate'] : 'match-all' ;
        $html .= "            <div class='action-block-filter-evaluate' style='display:inline;'>";
        $html .= '                <div class="btn-group" data-toggle="buttons">';
        $html .= '                    <label class="btn btn-default ' . ( $block['action_block_filters_evaluate'] == 'match-all'  ? 'active' : '' ) .'">';
        $html .= '                      <input type="radio" name="action_block_filters_evaluate[' . $action_block_id . ']" value="match-all" ' . ( $block['action_block_filters_evaluate'] == 'match-all'  ? 'checked="checked"' : '' ) .' > ' . __('Match All', 'inbound-pro');
        $html .= '                    </label>';
        $html .= '                    <label class="btn btn-default ' . ( $block['action_block_filters_evaluate'] == 'match-any'  ? 'active' : '' ) .'">';
        $html .= '                          <input type="radio" name="action_block_filters_evaluate[' . $action_block_id . ']" value="match-any" ' . ( $block['action_block_filters_evaluate'] == 'match-any'  ? 'checked="checked"' : '' ) .'> ' . __('Match Any', 'inbound-pro');
        $html .= '                    </label>';
        $html .= '                    <label class="btn btn-default ' . ( $block['action_block_filters_evaluate'] == 'match-none'  ? 'active' : '' ) .'"  >';
        $html .= '                         <input type="radio" name="action_block_filters_evaluate[' . $action_block_id . ']" value="match-none" ' . ( $block['action_block_filters_evaluate'] == 'match-none'  ? 'checked="checked"' : '' ) .'> ' . __('Match None', 'inbound-pro');
        $html .= '                    </label>';
        $html .= '                </div>';
        $html .= "            </div>";

        /* Add Action Filters Here */
        $html .= '            <div class="action-block-filters-container" data-action-block-id="' . $action_block_id . '" >';


        /* Prepare Filters if Action Block Manually Evoked */
        if (isset($block['filters'])) {

            if (count($block['filters'])<1) {
                $html .= '<div class="well well-sm action-contitions-well"><i>'.__( 'No conditions set' , 'inbound-pro' ) .'</i></div>';
            }

            foreach ($block['filters'] as $child_id => $filter) {

                $args = array('action_filter_id' => $filter['action_filter_id'], 'action_block_id' => $action_block_id, 'child_id' => $child_id, 'defaults' => $filter);

                $html .= self::ajax_build_db_lookup_filter($args);

            }
        }

        $html .= "              </div>";
        $html .= "      </div>";

        /* Start Then Actions */
        $html .= "      <div class='action-block-actions'>";
        $html .= "          <h2  class='action-block-section-header'>" . __('Actions to perform if conditions are met', 'inbound-pro') . "</h2>";

        /* Add Then Action Buttons */
        $html .= '            <div class="dropdown-add-actions" data-block-id="' . $action_block_id . '"  data-action-type="then" >';
        $html .= '                <span class="dropdown-toggle add-actions" data-block-id="' . $action_block_id . '"  data-action-type="then"  type="button"  data-toggle="dropdown">';
        $html .= '                   <i class="fa fa-plus-circle"></i>';
        $html .= '                </span>';
        $html .= '                <ul class="dropdown-menu dropdown-menu-left action-options" role="menu" aria-labelledby="menu1" >';
        $html .= '               </ul>';
        $html .= '            </div>';

        /* Add Then Actions Here */
        $html .= "            <div class='action-block-then-actions-container'  >";

        /* Prepare Actions if Action Block Manually Evoked */
        if (isset($block['actions']['then'])) {

            //print_r($block);
            foreach ($block['actions']['then'] as $child_id => $action) {

                $args = array('action_name' => $action['action_name'], 'action_type' => 'then', 'action_block_id' => $action_block_id, 'child_id' => $child_id, 'input_action_name_name' => 'action_name', 'defaults' => $action);

                $html .= self::ajax_build_action($args);

            }
        }

        $html .= "              </div>";
        $html .= "      </div>";

        /* Start Else Actions  */
        $html .= "      <div class='action-block-actions'>";
        $html .= "          <h2  class='action-block-section-header'>" . __('Actions to perform if conditions are not met', 'inbound-pro') . "</h2>";

        /* Add Else Action Buttons */
        $html .= '            <div class="dropdown-add-actions" data-block-id="' . $action_block_id . '"  data-action-type="else" >';
        $html .= '                <span class="dropdown-toggle add-actions" data-block-id="' . $action_block_id . '"  data-action-type="then"  type="button"  data-toggle="dropdown">';
        $html .= '                   <i class="fa fa-plus-circle"></i>';
        $html .= '                </span>';
        $html .= '                <ul class="dropdown-menu dropdown-menu-left action-options" role="menu" aria-labelledby="menu1" >';
        $html .= '               </ul>';
        $html .= '            </div>';

        /* Add Else Actions here */
        $html .= "              <div class='action-block-else-actions-container'>";

        /* Prepare Actions if Action Block Manually Evoked */
        if (isset($block['actions']['else'])) {

            //print_r($block);
            foreach ($block['actions']['else'] as $child_id => $action) {

                $args = array('action_name' => $action['action_name'], 'action_type' => 'else', 'action_block_id' => $action_block_id, 'child_id' => $child_id, 'input_action_name_name' => 'action_name', 'defaults' => $action);

                $html .= self::ajax_build_action($args);
            }
        }

        $html .= "              </div>";
        $html .= "      </div>";
        $html .= "</div>";
        $html .= "</div></div>";


        if (defined('DOING_AJAX') && DOING_AJAX) {
            echo $html;
            die();
        } else {
            return $html;
        }
    }

    /***
     * Ajax listener - build the html for a trigger filter
     */
    public static function ajax_build_trigger_filter($args) {

        $args =  ( !is_array($args) || !$args ) ? array() : $args;

        /* loads automation definitions */
        self::load_definitions();

        /* Get Parameters */
        $args['trigger_id'] = (isset($args['trigger_id'])) ? $args['trigger_id'] :  sanitize_text_field($_REQUEST['trigger_id']);
        $args['trigger_filter_id'] = (isset($args['trigger_filter_id'])) ? $args['trigger_filter_id'] : sanitize_text_field($_REQUEST['trigger_filter_id']);
        $args['child_id'] = (isset($args['child_id'])) ? $args['child_id'] : sanitize_text_field($_REQUEST['child_id']);
        $args['defaults'] = (isset($args['defaults'])) ? $args['defaults'] : sanitize_text_field($_REQUEST['defaults']);

        /* Die If No Filter Selected */
        if ($args['trigger_filter_id'] == '-1' && defined('DOING_AJAX') && DOING_AJAX) {
            die();
        } else if ($args['trigger_filter_id'] == '-1') {
            return '';
        }

        $key_args = array(
            'name' => 'trigger_filter_key',
            'type' => self::$argument_filters[$args['trigger_id']][$args['trigger_filter_id']]['key_input_type'],
            'options' => self::$argument_filters[$args['trigger_id']][$args['trigger_filter_id']]['keys'],
            'child_id' => $args['child_id'],
            'default' => $args['defaults'],
            'class' => 'trigger-filter-key'
        );


        $compare_args = array('name' => 'trigger_filter_compare', 'type' => 'dropdown', 'options' => self::$argument_filters[$args['trigger_id']][$args['trigger_filter_id']]['compare'], 'child_id' => $args['child_id'], 'default' => $args['defaults'], 'class' => 'trigger-filter-compare');

        $value_args = array('name' => 'trigger_filter_value', 'type' => self::$argument_filters[$args['trigger_id']][$args['trigger_filter_id']]['value_input_type'], 'options' => self::$argument_filters[$args['trigger_id']][$args['trigger_filter_id']]['values'], 'child_id' => $args['child_id'], 'default' => $args['defaults'], 'class' => 'trigger-filter-value');

        $key_input = self::build_input($key_args);
        $compare_input = self::build_input($compare_args);

        //print_r(self::$argument_filters);
        //print_r($compare_args);
        //echo $compare_input;
        $value_input = self::build_input($value_args);

        $header_name = str_replace('_', ' ', $args['trigger_filter_id']);
        $header_name = ucfirst(strtolower($header_name));

        $html = "<div class='filter-container'>";
        $html .= "<div><table class='table-filter' data-child-id='" . $args['child_id'] . "'>";
        $html .= "  <tr class='tr-filter'>";
        $html .= "      <td class='td-filter-key'>";
        $html .= "          <input type='hidden' name='trigger_filter_id[" . $args['child_id'] . "]' value='" . $args['trigger_filter_id'] . "'>";
        $html .= $key_input;
        $html .= "      </td>";
        $html .= "      <td class='td-filter-compare'>";
        $html .= $compare_input;
        $html .= "      </td>";
        $html .= "      <td class='td-filter-value'>";
        $html .= $value_input;
        $html .= "      </td>";
        $html .= "      <td class='td-filter-delete'>";
        $html .= '          <span class="btn btn-default btn-mini delete-filter" title="' . __('Delete Trigger Filter', 'inbound-pro') . '" id="bigtest"><i class="fa fa-times"></i></span>';
        $html .= "      </td>";
        $html .= "  </tr>";
        $html .= "</table>";
        $html .= "</div></div>";

        if (defined('DOING_AJAX') && DOING_AJAX) {
            echo $html;
            die();
        } else {
            return $html;
        }
    }

    /* AJAX - Build DB Lookup Filter HTML */
    public static function ajax_build_db_lookup_filter($args) {

        $args =  ( !is_array($args) || !$args ) ? array() : $args;

        /* loads automation definitions */
        self::load_definitions();

        /* Get Parameters */
        $args['action_filter_id'] = (isset($args['action_filter_id'])) ? $args['action_filter_id'] : sanitize_text_field($_REQUEST['action_filter_id']);
        $args['action_block_id'] = (isset($args['action_block_id'])) ? $args['action_block_id'] : intval($_REQUEST['action_block_id']);
        $args['child_id'] = (isset($args['child_id'])) ? $args['child_id'] : sanitize_text_field($_REQUEST['child_id']);
        $args['defaults'] = (isset($args['defaults'])) ? $args['defaults'] : sanitize_text_field($_REQUEST['defaults']);

        /* Get Filter Definitions */
        $this_filter = $args['action_filter_id'];

        /* Die If No Filter Selected */
        if ($this_filter == '-1' && defined('DOING_AJAX') && DOING_AJAX) {
            die();
        } else if ($this_filter == '-1') {
            return '';
        }

        $key_args = array('name' => 'action_filter_key', 'type' => self::$db_lookup_filters[$this_filter]['key_input_type'], 'options' => self::$db_lookup_filters[$this_filter]['keys'], 'action_block_id' => $args['action_block_id'], 'child_id' => $args['child_id'], 'default' => $args['defaults'], 'class' => 'action-filter-key');

        $compare_args = array('name' => 'action_filter_compare', 'type' => 'dropdown', 'options' => self::$db_lookup_filters[$this_filter]['compare'], 'action_block_id' => $args['action_block_id'], 'child_id' => $args['child_id'], 'default' => $args['defaults'], 'class' => 'action-filter-compare');

        $value_args = array('name' => 'action_filter_value', 'type' => self::$db_lookup_filters[$this_filter]['value_input_type'], 'options' => self::$db_lookup_filters[$this_filter]['values'], 'action_block_id' => $args['action_block_id'], 'child_id' => $args['child_id'], 'default' => $args['defaults'], 'class' => 'action-filter-value');

        $key_input = self::build_input($key_args);
        $compare_input = self::build_input($compare_args);
        $value_input = self::build_input($value_args);
        $header_name = str_replace('_', ' ', $this_filter);
        $header_name = ucfirst(strtolower($header_name));

        $html = "<div class='filter-container'>";
        $html .= '<table class="table-filter" data-child-id="' . $args['child_id'] . '">';
        $html .= "  <tr class='tr-filter'>";
        $html .= "      <td class='td-filter-type'>";
        $html .= "          <input type='hidden' name='action_filter_id" . (isset($args['action_block_id']) && $args['action_block_id'] ? '[' . $args['action_block_id'] . ']' : '') . "[" . $args['child_id'] . "]' value='" . $this_filter . "'>";
        $html .= $header_name . ':';
        $html .= "      </td>";
        $html .= "      <td class='td-filter-key'>";
        $html .= $key_input;
        $html .= "      </td>";
        $html .= "      <td class='td-filter-compare'>";
        $html .= $compare_input;
        $html .= "      </td>";
        $html .= "      <td class='td-filter-value'>";
        $html .= $value_input;
        $html .= "      </td>";
        $html .= "      <td class='td-filter-delete'>";
        $html .= '          <div class="action-filter-delete">';
        $html .= '              <span class="delete-filter" title="' . __('Delete Action Filter', 'inbound-pro') . '" data-block-id="' . $args['action_block_id'] . '" data-child-id="' . $args['child_id'] . '">';
        $html .= '                  <i class="fa fa-times"></i>';
        $html .= '              </span>';
        $html .= '          </div>';
        $html .= "      </td>";
        $html .= "  </tr>";
        $html .= "</table>";
        $html .= "</div>";

        if (defined('DOING_AJAX') && DOING_AJAX) {
            echo $html;
            die();
        } else {
            return $html;
        }
    }


    /**
     * AJAX - Build Action HTML
     */
    public static function ajax_build_action($args) {


        $args =  ( !is_array($args) || !$args ) ? array() : $args;

        /* loads automation definitions */
        self::load_definitions();

        /* Get Parameters */
        $args['action_name'] = (isset($args['action_name'])) ? $args['action_name'] : sanitize_text_field($_REQUEST['action_name']);
        $args['action_type'] = (isset($args['action_type'])) ? $args['action_type'] : sanitize_text_field($_REQUEST['action_type']);
        $args['action_block_id'] = (isset($args['action_block_id'])) ? $args['action_block_id'] : intval($_REQUEST['action_block_id']);
        $args['child_id'] = (isset($args['child_id'])) ? $args['child_id'] : sanitize_text_field($_REQUEST['child_id']);
        $args['defaults'] = (isset($args['defaults'])) ? $args['defaults'] : sanitize_text_field($_REQUEST['defaults']);

        $this_action = $args['action_name'];

        /* Die If No Action Selected */
        if ($this_action == '-1' && defined('DOING_AJAX') && DOING_AJAX) {
            die();
        } else if ($this_action == '-1') {
            return '';
        }

        $header_name = str_replace('_', ' ', $this_action);
        $header_name = ucfirst(strtolower($header_name));

        $html = "<div class='action-sub-wrapper' data-action-type='" . $args['action_type'] . "' data-block-id='" . $args['action_block_id'] . "'  data-child-id='" . $args['child_id'] . "'>";
        $html .= "<h4>";
        $html .= $header_name;
        $html .= '<i class="fa fa-info-circle inbound_tooltip" data-toggle="tooltip" data-placement="right" title="'. self::$actions[$this_action]['description'].'"></i>';
        $html .= '        <div class="action-buttons">';
        $html .= '          <span class="up-action-order" title=" ' . __('Move up', 'inbound-pro') . '"  data-block-id="' . $args['action_block_id'] . '"  data-child-id="' . $args['child_id'] . '" data-action-type="'.$args['action_type'].'"><i class="fa fa-arrow-up"></i> </span>';
        $html .= '          <span class="down-action-order" title=" ' . __('Move down', 'inbound-pro') . '"  data-block-id="' . $args['action_block_id'] . '"  data-child-id="' . $args['child_id'] . '" data-action-type="'.$args['action_type'].'"><i class="fa fa-arrow-down"></i> </span>';
        $html .= '          <span class="delete-action" title=" ' . __('Delete Action Block', 'inbound-pro') . '"  data-block-id="' . $args['action_block_id'] . '"  data-child-id="' . $args['child_id'] . '" data-action-type="'.$args['action_type'].'"><i class="fa fa-times"></i> </span>';
        $html .= '        </div>';
        $html .= '</h4>';
        $html .= '<div class="action-container">';
        $html .= "  <table class='table-action' data-child-id='" . $args['child_id'] . "'>";
        $html .= "      <tr class='tr-action'>";
        $html .= "          <td class='td-action-setting-label' colspan=2>";
        $html .= "              <input type='hidden' name='action_name[" . $args['action_block_id'] . "][" . $args['action_type'] . "][" . $args['child_id'] . "]' value='" . $this_action . "' data-id='action_name'>";
        $html .= "          </td>";
        $html .= "      </tr>";

        /* Build Settings for this Action */
        foreach (self::$actions[$this_action]['settings'] as $setting) {
            $setting['description'] = (isset($setting['description'])) ? $setting['description'] : '';

            /* Map Arguments for Generating Action Setting */
            $setting_args = array('name' => $setting['id'], 'action_name' => $args['action_name'], 'action_type' => $args['action_type'], 'action_block_id' => $args['action_block_id'], 'type' => $setting['type'], 'child_id' => $args['child_id'], 'class' => $setting['id']);

            /* Setup Default Values */
            if (isset($args['defaults'][$setting['id']])) {    /* If Generating From History Use Historic Value */

                $setting_args['default'][$setting['id']] = $args['defaults'][$setting['id']];

            } else if (isset($setting['default'])) { /* Else Use Default Action Value as defined in action definition If Available */

                $setting_args['default'][$setting['id']] = $setting['default'];
            }

            /* Set Options if Available */
            (isset($setting['options']) && is_array($setting['options'])) ? $setting_args['options'] = $setting['options'] : $settings_args['options'] = null;

            /* Generate Action Setting HTML */
            $setting_html = ( $setting_args['type'] == 'html' ) ? $setting['default'] : self::build_input($setting_args);
            if ( $setting['type'] == 'html' ) {

            }
            /* prepare hidden fields */
            $class = '';
            if (isset($setting['hidden']) && $setting['hidden']) {
                $class = 'hide-field';
            }

            /* prepare reveal rules */
            $extras = '';
            if (isset($setting['reveal']) && is_array($setting['reveal'])) {
                $extras = ' data-reveal-selector="' . $setting['reveal']['selector'] . '" data-reveal-value="' . $setting['reveal']['value'] . '" ';
            }

            /* Print Action Setting Label and Input */
            $html .= "  <tr class='tr-action-child {$class}' " . $extras . " >";
            $html .= "      <td class='td-action-setting-label'>";
            $html .= "          " . $setting['label'];
            $html .= "      </td>";
            $html .= "      <td class='td-action-setting-value'>";
            $html .= "          " . $setting_html . '<i class="fa fa-info-circle inbound_tooltip" data-toggle="tooltip" data-placement="right" title="'. $setting['description'].'"></i>';
            $html .= "      </td>";
            $html .= "  </tr>";

        }


        $html .= "</table>";
        $html .= "</div></div>";

        if (defined('DOING_AJAX') && DOING_AJAX) {
            echo $html;
            die();
        } else {
            return $html;
        }
    }

    /**
     *    Ajax Listener - Get's arguments associated with trigger as defined in trigger definition file
     */
    public static function ajax_load_trigger_arguments() {

        $target_trigger = sanitize_text_field($_REQUEST['trigger']);

        /* loads automation definitions */
        self::load_definitions();

        $filter_whitelist = array();

        if (!isset(self::$triggers[$target_trigger]['arguments'])) {
            echo json_encode(array(array('id' => '0', 'label' => 'Error: No Filters for Selected Trigger')));
            exit;
        }

        foreach (self::$triggers[$target_trigger]['arguments'] as $filter) {
            $filter_whitelist[] = array('id' => $filter['id'], 'label' => $filter['label']);
        }

        echo json_encode($filter_whitelist);
        die();
    }

    /**
     *    AJAX - Get DB Lookup Filters by Selected Trigger
     */
    public static function ajax_load_db_lookup_filters() {

        if (!isset($_REQUEST['trigger'])) {
            exit;
        }

        /* loads automation definitions */
        self::load_definitions();

        $target_trigger = sanitize_text_field($_REQUEST['trigger']);

        $filter_whitelist = array();


        if (!isset(self::$triggers[$target_trigger]['db_lookup_filters'])) {
            echo json_encode(array(array('id' => '0', 'label' => 'Error: No Filters for Selected Trigger')));
            exit;
        }

        foreach (self::$triggers[$target_trigger]['db_lookup_filters'] as $filter) {
            $filter_whitelist[] = array('id' => $filter['id'], 'label' => $filter['label']);
        }

        echo json_encode($filter_whitelist);
        die();
    }


    /**
     *    AJAX - Get Actions by Selected Trigger
     */
    public static function ajax_load_action_definitions() {

        /* loads automation definitions */
        self::load_definitions();

        $target_trigger = sanitize_text_field($_REQUEST['trigger']);

        $action_whitelist = array();

        if (!isset(self::$triggers[$target_trigger]['actions'])) {
            echo json_encode(array(array('id' => '0', 'label' => 'Error: No Filters for Selected Trigger')));
            exit;
        }

        foreach (self::$actions as $action) {
            if (in_array($action['id'], self::$triggers[$target_trigger]['actions'])) {
                $action_whitelist[] = array('id' => $action['id'], 'label' => $action['label']);
            }
        }

        echo json_encode($action_whitelist);
        die();
    }

    /**
     * Clear logs
     */
    public static function ajax_clear_logs() {
        update_post_meta( intval($_REQUEST['rule_id']) , '_automation_logs' ,  null );
        echo 'cleared';
        exit;
    }


    /**
     *    Build Filter Input HTML - Generates ( Key , Compare , Value )
     */
    public static function build_input($args) {
        $html = '';

        $block_id = (isset($args['action_block_id'])) ? $args['action_block_id'] : '';
        $child_id = (isset($args['child_id'])) ? $args['child_id'] : '';
        $action_type = (isset($args['action_type'])) ? $args['action_type'] : '';

        /* construct input name */
        $name = $args['name'] . ($block_id ? '[' . $block_id . ']' : '') . ($action_type ? '[' . $action_type . ']' : '') . '[' . $args['child_id'] . ']';

        /* setup default */
        $default = (isset($args['default'][$args['name']])) ? $args['default'][$args['name']] : '';

        switch ($args['type']) {
            case 'dropdown' :
                //echo $args['name'].':'.$args['default'][$args['name']].'<br>';
                $html .= '<select name="' . $name . '" class="' . $args['class'] . '" data-block-id="' . $block_id . '" data-child-id="' . $child_id . '" data-id="' . $args['name'] . '">';
                foreach ($args['options'] as $id => $label) {
                    /* Make sure dropdown label is no too large */
                    $label = (strlen($label) > 200) ? substr($label,0,200).'...' : $label;

                    $html .= '<option value="' . $id . '" ' . ($default == $id ? 'selected="selected"' : '') . '>' . $label . '</option>';
                }
                $html .= '</select>';
                break;
            case 'select2' :


                if (!$default) {
                    $default = array();
                }

                //echo $args['name'].':'.$args['default'][$args['name']].'<br>';
                $html .= '<select name="' . $name . '[]" class="' . $args['class'] . ' select2" data-block-id="' . $block_id . '" data-child-id="' . $child_id . '"  data-id="' . $args['name'] . '"  multiple>';
                foreach ($args['options'] as $id => $label) {
                    $html .= '<option value="' . $id . '" ' . (in_array($id, $default) ? 'selected="selected"' : '') . '>' . $label . '</option>';
                }
                $html .= '</select>';
                break;
            case 'text':
                $html .= '<input type="text" name="' . $name . '" value="' . str_replace('"' , '&quot;' , $default) . '" data-block-id="' . $block_id . '" data-child-id="' . $child_id . '"  data-id="' . $args['name'] . '">';
                break;
            case 'html':
                $html .=  $args['options'];
                break;
            case 'checkbox':

                $html .= '<table >';

                foreach ($args['options'] as $id => $label) {
                    $html .= '<tr>';
                    $html .= '<td data-field-type="checkbox">';
                    $html .= '<input type="checkbox"    name="' . $name . '[]" class="' . $args['class'] . '"  data-id="' . $args['name'] . '" value="' . $id . '" ' . (isset($args['default'][$args['name']]) && in_array($id, $args['default'][$args['name']]) ? 'checked="checked"' : '') . '>';
                    $html .= '<label for="' . $id . '">&nbsp;&nbsp;' . $label . '</label>';
                    $html .= '</td>';
                    $html .= "</tr>";
                }

                $html .= "</table>";

                //$html .=  '<div class="lp_tooltip tool_checkbox" title="'.$field['description'].'"></div>';
                break;
        }

        return $html;
    }

    /* Sets screen columns to 1 */
    public static function screen_layout_columns( $columns ) {
        return true;
    }
}


/**
 * Hook loads Inbound_Metaboxes_Automation at plugins_loaded filter
 * @package Automation
 */
function inbound_automation_metaboxes() {
    new Inbound_Metaboxes_Automation;
}

add_action('plugins_loaded', 'inbound_automation_metaboxes', 21);
Inbound Pro Plugin - PHP Codex API documentation generated by ApiGen