and
tags to content which was causing issues w/EASE parsing remove_filter( 'the_content', 'wpautop' ); add_filter( 'wp_page_menu_args', 'ease_page_menu_args' ); // run the form/oauth actions before anything else add_action('init', 'ease_form_process'); // run the content through the parser add_filter( 'the_content', 'ease_filter' ); // readd the removed filters add_filter( 'the_content', 'wpautop' ); add_filter( "the_content", "wptexturize"); }else{ $pagename = $_REQUEST['page']; $request_path_parts = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); add_action('admin_menu', 'ease_plugin_menu'); add_action( 'admin_init', 'register_ease_setting' ); add_action( 'admin_init', 'ease_admin_load_js_scripts' ); add_action('admin_init', 'ease_plugin_activate_redirect'); add_filter('admin_footer_text', 'ease_remove_footer_admin'); add_action( 'admin_footer', 'ease_disable_html_editor_wps' ); if($_REQUEST['page'] == "ease_plugin_settings" || $_REQUEST['page'] == "ease_landing_page"){ add_action( 'admin_footer', 'ease_drive_settings_modal_div'); } add_filter( 'wp_default_editor', create_function('', 'return "html";') ); add_filter('media_buttons_context', 'ease_script_helper'); if(get_option('ease_gapp_client_id')){ add_action( 'add_meta_boxes', 'adding_custom_ease_meta_box_pullfromdrive', 10, 2 ); } add_action('wp_ajax_ease_add_new_page', 'easeAddNewPage'); add_action( 'add_meta_boxes', 'adding_custom_ease_meta_boxes', 10, 2 ); add_action( 'wp_ajax_save_ease_settings_modal_values', 'save_ease_settings_modal_values' ); add_action( 'save_post', 'ease_save_meta_box_data' ); register_activation_hook( __FILE__, 'ease_plugin_activate' ); } /** * Sets the option to redirect to the plugin page when activated * * @author Lucas Simmons * * @since 0.1.1 * */ function ease_plugin_activate() { add_option('ease_plugin_do_activation_redirect', true); } /** * Does the actual redirect for ease_plugin_activate * * @author Lucas Simmons * * @since 0.1.1 * */ function ease_plugin_activate_redirect(){ if (get_option('ease_plugin_do_activation_redirect', false)) { delete_option('ease_plugin_do_activation_redirect'); wp_redirect(admin_url() . 'admin.php?page=ease_landing_page'); exit; } } /** * Excludes no show urls from being displayed * * @author Lucas Simmons * * @since 0.1.0 * */ function ease_page_menu_args( $args ) { $exclude_args = get_option("ease_no_show_urls"); $arg_string = ""; if(is_array($exclude_args)){ foreach($exclude_args as $i => $arg){ $arg_string .= $arg . ","; } $arg_string = substr($arg_string, 0, -1); } if($arg_string){ $arg_string .= ","; } $arg_string .= get_option('ease_service_endpoint_page'); $args['exclude'] = $arg_string; return $args; } /** * Queues javascripts * * @author Lucas Simmons * * @since 0.1.0 * */ function ease_admin_load_js_scripts(){ wp_enqueue_script('ease_my_script', plugins_url( 'script_helper.js' , __FILE__ ),array(),"0.1.7.180853"); wp_enqueue_script('ease_my_script1', plugin_dir_url( __FILE__ ) . "static/js/tabslet/jquery.tabslet-custom.js","","",true); wp_enqueue_script('ease_my_script2', plugin_dir_url( __FILE__ ) . "static/js/jquery-validation/validation-1.13.0/dist/jquery.validate.js","","",true); } /** * Handles form actions * * @author Lucas Simmons * * @since 0.1.0 * */ function ease_form_process(){ ob_start(); $service_endpoint = $_REQUEST['endpoint']; if($service_endpoint == "oauth2callback") { session_start(); $ease_core = ease_load_core(); $ease_core->handle_google_oauth2callback(); exit; }elseif($_POST['ease_form_id'] && $service_endpoint == "ease_form"){ session_start(); $ease_core = ease_load_core(); $ease_core->handle_form(); if(strpos($_SERVER['HTTP_REFERER'],'/wp-admin/admin.php?')){ exit; } // This causes the page to redirect exit; } } /** * Generates the content that shows under a post's edit page * * @author Lucas Simmons * * @since 0.1.0 * */ function ease_disable_html_editor_wps() { echo ''; add_thickbox(); echo ' '; } /** * Runs the passed content through the EASE parser and echoes the result * * @author Lucas Simmons * * @since 0.1.0 * * @param string $content The content you want to run through the EASE parser */ function ease_filter( $content) { session_start(); // Only run the plugin if there is an ease tag. No need to add this extra processing where it does not exist if((strpos($content,"<#") !== false) || (strpos($content,"<#") !== false)){ $ease_core = ease_load_core(); // Sometimes and symbols are converted to their html equivalent $content = str_replace("&",'&',$content); // If they used the visual text editor, then their EASE tags will be converted into the html equivalent - replacing these values should work most of the time $content = str_replace("<#","<#",$content); $content = str_replace("#>","#>",$content); if(version_compare(PHP_VERSION, '5.4.0')<0) { echo "You need to be running a version of PHP greater than 5.4.0 for this plugin to work

"; echo $content; }else{ require_once('ease_content_replace.php'); //if(!preg_match('/(.*?)(<#\s*([^\s\[\'"].*|$))/i', $body_line)) { $content = replace_ease_urls($content); $this_content = $ease_core->process_ease($content,true); echo $this_content; } }else{ return $content; } if($_POST['ease_form_id']){ ob_flush(); } } /** * Replaces EASE urls with the WordPress permalinks * * @author Lucas Simmons * * @since 0.1.1 * * @param string $content The content you want to scan for ease links (/?page=page_name or ?page=page_name) */ function replace_ease_urls($content){ //$content = preg_replace('/bodypage\s*=\s*"(.*?)"\s*;/is', "$1" . get_permalink($link_id), $content); $replace_urls = get_option( "ease_replace_urls"); // Replaces the urls with the wordpress permalink url if($replace_urls){ foreach($replace_urls as $index => $link_id){ // Replaces any urls that end in (space/line break)#> for things like restrict access... probably should make this search through ease tags $content = preg_replace('/(\/\?page=((' . $index . ')))(?=\s*#>)/', get_permalink($link_id), $content); // Replace any urls that have a start of a quote and end of a quote or ? or & and are formatted like /?page=page_name with the permalink url if(strpos(get_permalink($link_id),"?") === false){ $content = preg_replace('/(\'|")+(\/\?page=((' . $index . ')))(?=\?|&|"|\')/', "$1" . get_permalink($link_id), $content); } // Searches for any permalinks that have the syntax /& when they should be /? if(get_permalink($link_id) !== false){ $content = preg_replace('/(' . preg_quote(get_permalink($link_id),'/') . '&)+/', get_permalink($link_id) . '?', $content); } } //foreach($replace_urls as $index => $link_id){ // $content = preg_replace('/(\?page=((' . $index . ')))(?=\?|&|"|\')/', get_permalink($link_id), $content); // $content = preg_replace('/(' . preg_quote(get_permalink($link_id),'/') . '(&))+/', get_permalink($link_id) . '?', $content); //} } // Any extra /?page= should be replaced with the site url as the base if(strpos(get_permalink($link_id),"?") === false){ $content = preg_replace('/((?:\'|")+\/\?page=)+/', site_url() . '?page=', $content); } return $content; } /** * Removes the footer the the ease plugin settings page * * @author Lucas Simmons * * @since 0.1.0 * * @param string $text The footer text * */ function ease_remove_footer_admin ($text) { if($_REQUEST['page'] != "ease_plugin_settings"){ echo $text; } } /** * The admin plugin settings page * * @author Lucas Simmons * * @since 0.1.0 */ function ease_plugin_settings(){ $endpoint_page_id = get_option('ease_service_endpoint_page'); if($endpoint_page_id === false || !$endpoint_page_id){ ease_load_core(); $endpoint_page_id = get_option('ease_service_endpoint_page'); } ?>

Cloudward EASE Framework Settings

View EASE Framework Welcome Page for getting started hints
   Your EASE handler page is missing, click here to regenerate it'; } if(!get_option('ease_gapp_client_id') || !get_option('ease_gapp_client_secret')){ if($notify_items_string){ $notify_items_string .= "
"; } $notify_items_string .= '   You have not completed your Google Settings'; } $created_ease_page = false; if(is_array($ease_page_array)){ foreach($ease_page_array as $key=>$value){ if($key && $value){ $created_ease_page = true; } } } if(!$created_ease_page){ if($notify_items_string){ $notify_items_string .= "
"; } $notify_items_string .= '   You have not created an EASE Helper Script page'; } if($notify_items_string){ echo "
Notifications:
" . $notify_items_string . "

"; } echo "
EASE Helper Scripts:
   Create EASE Page and Collections or see EASE Code examples:
   Pages include: Members website, contacts, surveys, store and more

"; $ease_page_array = get_option('ease_replace_urls'); ?> You need to be running a version of PHP greater than 5.4.0 for this plugin to work"; exit; } $ease_disable_db_access = ""; if(get_option('ease_disable_db_access')){ $ease_disable_db_access = "checked=checked"; } ?>

>   Enable Google Drive Access - Setup

          (To activate connectivity to Google Drive, Sheets and Docs)

File Upload/Download Options (pick one)

>   Enable upload/downloads to Amazon S3 - Setup

          (Activate Upload/Downloads to Amazon S3 rather than your hosting site's folder)

>   Enable upload/downloads to your hosted sites folder - Setup

          (Activate uploads/downloads to your hosted sites folder)

=0) { ease_load_core(); } if($_GET['ease_admin_debug']){ echo "======
Begin Server Info

Php Version: " . PHP_VERSION . "

"; foreach($_SERVER as $key=>$value){ if(!is_array($value)){ echo $key . ": " . $value . "
"; }else{ echo $key . ": " . print_r($value,true) . "
"; } } echo "End Server Info
======

"; } ease_plugin_settings(); echo " "; add_thickbox(); echo ''; if($_GET['ease_do_not_show_welcome'] == "y"){ update_option('ease_has_shown_install_popup',true); }elseif($_GET['ease_do_not_show_welcome'] == "n"){ update_option('ease_has_shown_install_popup',""); } if(!get_option('ease_has_shown_install_popup')){ add_thickbox(); echo ' '; }else{ echo ' '; } } /** * Initializing EASE Settings * * @author Lucas Simmons * * @since 0.1.0 * */ function register_ease_setting() { register_setting( 'easeoption-group', 'ease_db_name' ); register_setting( 'easeoption-group', 'ease_project_id' ); register_setting( 'easeoption-group1', 'ease_google_drive_active' ); register_setting( 'easeoption-group', 'ease_gapp_client_id' ); register_setting( 'easeoption-group', 'ease_gapp_client_secret' ); register_setting( 'easeoption-group1', 'ease_s3_active' ); register_setting( 'easeoption-group', 'ease_s3_bucket_public' ); register_setting( 'easeoption-group', 'ease_s3_bucket_private' ); register_setting( 'easeoption-group', 'ease_s3_access_key' ); register_setting( 'easeoption-group', 'ease_s3_secret_access_key' ); register_setting( 'easeoption-group', 'ease_has_shown_install_popup' ); register_setting( 'easeoption-group1', 'ease_local_upload_active' ); register_setting( 'easeoption-group', 'ease_public_folder_upload_directory' ); register_setting( 'easeoption-group', 'ease_private_folder_upload_directory' ); register_setting( 'easeoption-group', 'ease_external_db_hostname' ); register_setting( 'easeoption-group', 'ease_external_db_user' ); register_setting( 'easeoption-group', 'ease_external_db_password' ); register_setting( 'easeoption-group', 'ease_disable_db_access' ); //ease_disable_db_access // register_setting( 'easeoption-group', 'ease_service_endpoint_page' ); } /** * Function to add the admin side plugin menu * * @author Lucas Simmons * * @since 0.1.0 * */ function ease_plugin_menu(){ add_menu_page('Welcome','Cloudward EASE Settings','manage_options','ease_landing_page','ease_landing_page'); add_submenu_page(null,'Create EASE Endpoint page','Create EASE Endpoint page','manage_options','create_ease_endpoint_page','create_ease_endpoint_page'); add_submenu_page(null,'Settings','Settings','manage_options','save_ease_settings_modal_values','save_ease_settings_modal_values'); } /** * Adds box at the bottom of the page for editing posts * * @author Lucas Simmons * * @since 0.1.0 * * @param string $post_type * @param string $post */ function adding_custom_ease_meta_boxes( $post_type, $post ) { add_meta_box( 'my-meta-box', __( 'EASE Page name' ), 'render_ease_meta_box', 'page', 'side', 'high' ); } /** * Adds box at the bottom of the page for saving the EASE page name * * @author Lucas Simmons * * @since 0.1.4 * * @param string $post_type */ function render_ease_meta_box($post){ $page_name = array_search($post->ID,get_option('ease_replace_urls')); if(!$page_name && $post->ID){ $post = get_post($post->ID); // $page_name = $post->post_name; } if($page_name && strpos($page_name,".espx") === false){ $page_name .= ".espx"; } wp_nonce_field( 'ease_meta_box', 'ease_meta_box_nonce' ); echo '
'; if($page_name){ echo 'Reference as: /?page=' . str_replace(".espx","",$page_name); } } /** * When the post is saved, saves our custom data. * * @param int $post_id The ID of the post being saved. */ function ease_save_meta_box_data( $post_id ) { /* * We need to verify this came from our screen and with proper authorization, * because the save_post action can be triggered at other times. */ // Check if our nonce is set. if ( ! isset( $_POST['ease_meta_box_nonce'] ) ) { return; } // Verify that the nonce is valid. if ( ! wp_verify_nonce( $_POST['ease_meta_box_nonce'], 'ease_meta_box' ) ) { return; } // If this is an autosave, our form has not been submitted, so we don't want to do anything. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Check the user's permissions. if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } } /* OK, it's safe for us to save the data now. */ // Make sure that it is set. if ( ! isset( $_POST['ease_file_page_name'] ) ) { return; } // Sanitize user input. $my_data = str_replace(".espx","",sanitize_text_field( $_POST['ease_file_page_name'] )); // Update the meta field in the database. $replace_urls = get_option( "ease_replace_urls"); $page_name = array_search($post_id,get_option('ease_replace_urls')); $result = array_keys($replace_urls,$post_id); foreach($result as $key=>$value){ unset($replace_urls[$value]); } if($page_name && $post_id){ unset($replace_urls[$page_name]); unset($replace_urls[$page_name . ".espx"]); } if($post_id){ $replace_urls[$my_data] = $post_id; delete_option("ease_replace_urls"); add_option( "ease_replace_urls", $replace_urls); } //update_post_meta( $post_id, '_my_meta_value_key', $my_data ); } /** * Saves the values for different services from the settings modal * * @author Lucas Simmons * * @since 0.1.5 * */ function save_ease_settings_modal_values(){ update_option('ease_gapp_client_id',$_POST['ease_gapp_client_id']); update_option('ease_gapp_client_secret',$_POST['ease_gapp_client_secret']); update_option('ease_project_id',$_POST['ease_project_id']); update_option('ease_db_name',$_POST['ease_db_name']); update_option('ease_disable_db_access',$_POST['ease_disable_db_access']); update_option('ease_s3_bucket_private',$_POST['ease_s3_bucket_private']); update_option('ease_s3_bucket_public',$_POST['ease_s3_bucket_public']); update_option('ease_s3_access_key',$_POST['ease_s3_access_key']); update_option('ease_s3_secret_access_key',$_POST['ease_s3_secret_access_key']); } /** * Includes the modals for settings in the plugin * * @author Lucas Simmons * * @since 0.1.5 * */ function ease_drive_settings_modal_div(){ include_once plugin_dir_path( __FILE__ ) . 'settings_modals.php'; } include_once plugin_dir_path( __FILE__ ) . 'plugin_function_includes.php'; ?>