. */ if( !defined( 'ABSPATH' ) ) { exit( 'You are not allowed to access this file directly.' ); } // Register style sheet. add_action('wp_enqueue_styles', 'agilecrm_forms_css' ); /** * Register style sheet. */ function agilecrm_forms_css() { wp_enqueue_style( 'agilecrm-forms', plugins_url( '/css/style.css', __FILE__ ) ); } add_action( 'wp', 'agilecrm_forms_landing_page_setpup', 10, 0 ); function agilecrm_forms_landing_page_setpup(){ if(!is_admin()){ global $post; $forms_landing_page = get_post_meta($post->ID, 'forms_landing_page',true); if($forms_landing_page != ""){ $domain = (sanitize_text_field(get_option( "forms_agile_domain" ))); $email= (sanitize_email(get_option( "forms_agile_email" ))); $rest_api = (sanitize_text_field(get_option( "forms_agile_rest_api" ))); if($domain != "" && $email != "" && $rest_api != ""){ $request = wp_remote_get('https://'.$domain.'.agilecrm.com/landing/'.$forms_landing_page); echo $response = wp_remote_retrieve_body( $request ); die(); } } } } add_action( 'init', 'agilecrm_forms_list_agile_form', 10, 0 ); function agilecrm_forms_list_agile_form(){ if(isset($_GET["agile_list_form"]) == 1){ $domain = (sanitize_text_field(get_option( "forms_agile_domain" ))); $email= (sanitize_email(get_option( "forms_agile_email" ))); $rest_api = (sanitize_text_field(get_option( "forms_agile_rest_api" ))); if($domain != "" && $email != "" && $rest_api != ""){ $agile_url = "https://" .$domain. ".agilecrm.com/dev/api/"; $headers = array( 'Authorization' => 'Basic ' . base64_encode( $email. ':' .$rest_api ), 'Content-type' => 'application/json', 'Accept' => 'application/json' ); $args = array( 'timeout' => 120, 'sslverify' => false, 'headers' => $headers ); $request = wp_remote_get($agile_url.'forms',$args); $result = wp_remote_retrieve_body( $request ); if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) { $result = json_decode($result,false, 512, JSON_BIGINT_AS_STRING); } else { $result = json_decode($result,false); } $data = array(); if(count($result) > 0){ foreach($result as $k => $v){ $tmp = array(); $tmp["text"] = $v->formName; $tmp["value"] = $v->id; $data[] = $tmp; } } echo json_encode($data); } die(); } } add_action('admin_menu', 'agilecrm_forms_create_menu'); function agilecrm_forms_create_menu() { add_menu_page('Agile CRM Forms', 'Agile CRM Forms', 'administrator', 'agilecrm_forms_dashboard', 'agilecrm_forms_dashboard_page',plugins_url( 'agile-crm-forms/images/icon.png' ),0); add_submenu_page('agilecrm_forms_dashboard', 'Home', 'Home', 'administrator', 'agilecrm_forms_dashboard', 'agilecrm_forms_dashboard_page'); add_submenu_page('agilecrm_forms_dashboard','Web Rules','Web Rules','administrator', 'agilecrm_forms_webrules', 'agilecrm_forms_webrules_page' ); add_submenu_page('agilecrm_forms_dashboard','Form Builder','Form Builder','administrator', 'agilecrm_forms_formbuilder', 'agilecrm_forms_formbuilder_page' ); add_submenu_page('agilecrm_forms_dashboard','Landing Pages','Landing Pages','administrator', 'agilecrm_forms_landing', 'agilecrm_forms_landing_page' ); add_submenu_page('agilecrm_forms_dashboard','Email Campaigns','Email Campaigns','administrator', 'agilecrm_forms_email', 'agilecrm_forms_email_page' ); add_submenu_page('agilecrm_forms_dashboard','Web Stats','Web Stats','administrator', 'agilecrm_forms_webstats', 'agilecrm_forms_webstats_page' ); add_submenu_page('agilecrm_forms_dashboard','Refer a Friend','Refer a Friend','administrator', 'agilecrm_forms_refer', 'agilecrm_forms_refer_page' ); add_submenu_page('agilecrm_forms_dashboard','Settings','Settings','administrator', 'agilecrm_forms_settings', 'agilecrm_forms_settings_page' ); } function agilecrm_forms_header($domain){ $forms_agile_email = (sanitize_email(get_option( "forms_agile_email" ))); $forms_agile_password = (sanitize_text_field(get_option( "forms_agile_password" ))); agilecrm_forms_css(); $page_name = $_GET['page']; if($page_name == 'agilecrm_forms_dashboard') { agilecrm_forms_hidedata_js(); ?>