. */ if( !defined( 'ABSPATH' ) ) { exit( 'You are not allowed to access this file directly.' ); } // Register style sheet. add_action('wp_enqueue_styles', 'agilecrm_landing_pages_css' ); /** * Register style sheet. */ function agilecrm_landing_pages_css() { wp_enqueue_style( 'agilecrm-landing-pages', plugins_url( '/css/style.css', __FILE__ ) ); } add_action( 'wp', 'agilecrm_landing_pages_landing_page_setpup', 10, 0 ); function agilecrm_landing_pages_landing_page_setpup(){ if(!is_admin()){ global $post; $landing_pages_landing_page = get_post_meta($post->ID, 'landing_pages_landing_page',true); if($landing_pages_landing_page != ""){ $domain = (sanitize_text_field(get_option( "landing_pages_agile_domain" ))); $email= (sanitize_email(get_option( "landing_pages_agile_email" ))); $rest_api = (sanitize_text_field(get_option( "landing_pages_agile_rest_api" ))); if($domain != "" && $email != "" && $rest_api != ""){ $request = wp_remote_get('https://'.$domain.'.agilecrm.com/landing/'.$landing_pages_landing_page); echo $response = wp_remote_retrieve_body( $request ); die(); } } } } add_action( 'init', 'agilecrm_landing_pages_list_agile_form', 10, 0 ); function agilecrm_landing_pages_list_agile_form(){ if(isset($_GET["agile_list_form"]) == 1){ $domain = (sanitize_text_field(get_option( "landing_pages_agile_domain" ))); $email= (sanitize_email(get_option( "landing_pages_agile_email" ))); $rest_api = (sanitize_text_field(get_option( "landing_pages_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_landing_pages_create_menu'); function agilecrm_landing_pages_create_menu() { add_menu_page('Agile CRM Landing Pages', 'Agile CRM Landing Pages', 'administrator', 'agilecrm_landing_pages_dashboard', 'agilecrm_landing_pages_dashboard_page',plugins_url( 'agilecrm-landing-pages/images/icon.png' ),0); add_submenu_page('agilecrm_landing_pages_dashboard', 'Home', 'Home', 'administrator', 'agilecrm_landing_pages_dashboard', 'agilecrm_landing_pages_dashboard_page'); add_submenu_page('agilecrm_landing_pages_dashboard','Web Rules','Web Rules','administrator', 'agilecrm_landing_pages_webrules', 'agilecrm_landing_pages_webrules_page' ); add_submenu_page('agilecrm_landing_pages_dashboard','Form Builder','Form Builder','administrator', 'agilecrm_landing_pages_formbuilder', 'agilecrm_landing_pages_formbuilder_page' ); add_submenu_page('agilecrm_landing_pages_dashboard','Landing Pages','Landing Pages','administrator', 'agilecrm_landing_pages_landing', 'agilecrm_landing_pages_landing_page' ); add_submenu_page('agilecrm_landing_pages_dashboard','Email Campaigns','Email Campaigns','administrator', 'agilecrm_landing_pages_email', 'agilecrm_landing_pages_email_page' ); add_submenu_page('agilecrm_landing_pages_dashboard','Web Stats','Web Stats','administrator', 'agilecrm_landing_pages_webstats', 'agilecrm_landing_pages_webstats_page' ); add_submenu_page('agilecrm_landing_pages_dashboard','Refer a Friend','Refer a Friend','administrator', 'agilecrm_landing_pages_refer', 'agilecrm_landing_pages_refer_page' ); add_submenu_page('agilecrm_landing_pages_dashboard','Settings','Settings','administrator', 'agilecrm_landing_pages_settings', 'agilecrm_landing_pages_settings_page' ); } function agilecrm_landing_pages_header($domain){ $landing_pages_agile_email = (sanitize_email(get_option( "landing_pages_agile_email" ))); $landing_pages_agile_password = (sanitize_text_field(get_option( "landing_pages_agile_password" ))); agilecrm_landing_pages_css(); $page_name = $_GET['page']; if($page_name == 'agilecrm_landing_pages_dashboard') { agilecrm_landing_pages_hidedata_js(); ?>