__( 'Primary Menu' ))); } // Enables Featured Image add_theme_support( 'post-thumbnails' ); ### # # Poll/Surveys # ### //function wrapper for survey form function meyers_survey_form($echo = true){ $args = array( 'post_type' => 'survey', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '0'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); $form .= '
'; //loop through the options to display if( have_rows('questions')): while(have_rows('questions')):the_row(); $form .= '
'; endwhile; //submit button // $form .= ''; endif; $form .= '
'; //check to see if we want the output echoed right now if($echo===true){ echo $form; } endwhile; wp_reset_postdata(); } function meyers_survey_results($echo = true){ $args = array( 'post_type' => 'survey', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '0'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); //loop through the options to display if( have_rows('questions')): while(have_rows('questions')):the_row(); $results[get_sub_field('options')] = get_sub_field('count'); endwhile; //sum $sum = array_sum($results); //convert to percentage foreach($results as $option => $count){ $results[$option] = round($count/$sum*100,1); //generate random hex value $rand = array('3', '4', '5', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'c', 'b'); $color = '#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)]; //create pie chart $return .= '
'.$option.': '.$results[$option].'%
'; } endif; //check to see if we want the output echoed right now if($echo===true){ echo $return; } endwhile; wp_reset_postdata(); } add_action('init','process_survey'); function process_survey(){ global $wpdb; if(!isset($_SESSION) or empty($_SESSION)){ session_start(); } if($_SESSION['survey_form_submited']==1){ return; } //make sure our form was posted if(isset($_POST['survey_option']) && !empty($_POST['survey_option'])){ //open up our repeater field $rows = $wpdb->get_results($wpdb->prepare( " SELECT * FROM wp_postmeta WHERE meta_key LIKE %s ", 'questions_%_options' // meta_name: $ParentName_$RowNumber_$ChildName )); if( $rows ){ foreach( $rows as $row ){ //regular expression to find our row number preg_match('_([0-9]+)_', $row->meta_key, $matches); //pre-define some keys $options_key = 'questions_' . $matches[0] . '_options'; $count_key = 'questions_'.$matches[0].'_count'; //get the current option $option = get_post_meta((int)$_POST['survey_id'],$options_key,true); //check to make sure this is the option the user wanted if($option === $_POST['survey_option']){ //get the current vote count $count = get_post_meta((int)$_POST['survey_id'],$count_key,true); //increment $count++; //update the field! $result = update_post_meta((int)$_POST['survey_id'],$count_key,$count,($count-1)); //set session variables to show results if($result===true){ $_SESSION['survey_form_submited'] = 1; } } } } } } ### # # Public Posts Form # ### function sanatize($input){ switch(gettype($input)){ case 'object': foreach($input as $key => $variable){ $key = sanatize($variable); } break; case 'array': foreach($input as $key => $variable){ $input[$key] = sanatize($variable); } break; case 'string': //remove poison null byte //remove blank space at beginging and end of string $input = trim(htmlentities(str_replace(chr(0),'',$input),ENT_QUOTES)); break; } return $input; } // //this needs to take place early // add_action('init','public_post_form'); // function public_post_form(){ // //check to see if our session is started - we need this for post limiters // if(!isset($_SESSION)){ // session_start(); // } // //create an alias for $_POST, because no one likes writing that out. // $p = sanatize($_POST); // //see if our form was submited // if(isset($p['public_post_form']) && !empty($p['public_post_form'])){ // $iph = $p['public_post_form']; // $current_iph = sha1($_SERVER['REMOTE_ADDR']); // //see if the IP address of the form matches the IP address of the current viewer (slight protection against botnets) // if($iph === $current_iph){ // //now comes data verification - we'll just check if things are set and not empty for now // if( isset($p['mail']) && !empty($p['mail']) && isset($p['name']) && !empty($p['name']) && isset($p['msg']) && !empty($p['msg']) ){ // //make sure the session hasn't posted too often // if($_SESSION['public_post_form']['last_post'] <= time()-(60*2)){ // $new_post = array( // 'post_content' => $p['msg'], // The full text of the post. // 'post_title' => $p['name'],// The title of your post. // 'post_status' => 'publish', // Default 'draft'. // 'post_type' => 'story', // Default 'post'. // 'post_author' => 3, // The user ID number of the author. Default is the current user ID. // 'ping_status' => 'closed', // Pingbacks or trackbacks allowed. Default is the option 'default_ping_status'. // //'post_date' => [ Y-m-d H:i:s ] // The time post was made. // //'post_date_gmt' => [ Y-m-d H:i:s ] // The time post was made, in GMT. // //'comment_status' => // Default is the option 'default_comment_status', or 'closed'. // //'post_category' => [ array(, ...) ] // Default empty. // //'tags_input' => [ ', , ...' | array ] // Default empty. // //'tax_input' => [ array( => ) ] // For custom taxonomies. Default empty. // //'page_template' => [ ] // Requires name of template file, eg template.php. Default empty. // ); // //insert our new post into wordpress // $new_id = wp_insert_post($new_post); // if(is_numeric($new_id) && $new_id > 0){ // //set our email field (ACF) // update_field('email',$p['mail'],$new_id); // //set our timer for posting // $_SESSION['public_post_form']['last_post'] = time(); // }else{ // die('ERROR POSTING TO WORDPRESS'); // } // }else{ // die('Posting too often -- please wait'); // }//end session check // }else{ // echo 'Some required fields were blank or invalid'; // //error handling can go here as needed // return; // }//end data verification // }//end IP match // }//end form origin test // }//end public_post_form() // // Registers a new post type for instagram // add_action( 'init', 'register_instagram_post' ); // function register_instagram_post() { // register_post_type( 'instagram', // array( // 'labels' => array( // 'name' => __( 'Instagram Feed' ), // 'singular_name' => __( 'Instagram Image' ), // 'add_new' => __( 'Add New' ), // 'add_new_item' => __( 'Add New' ), // 'edit_item' => __( 'Edit' ), // 'new_item' => __( 'Add New' ), // 'view_item' => __( 'View' ), // 'search_items' => __( 'Search' ), // 'not_found' => __( 'No posts found' ), // 'not_found_in_trash' => __( 'No posts found in trash' ) // ), // 'menu_icon' => 'dashicons-format-gallery', // 'public' => true, // 'has_archive' => true, // 'supports' => array( 'title', 'thumbnail'), // 'capability_type' => 'post', // 'rewrite' => array("slug" => "instagram"), // Permalinks format // // 'menu_position' => 5, // ) // ); // } // Registers a new post type for stories add_action( 'init', 'register_story_post' ); function register_story_post() { register_post_type( 'story', array( 'labels' => array( 'name' => __( 'Stories' ), 'singular_name' => __( 'Story' ), 'add_new' => __( 'Add New' ), 'add_new_item' => __( 'Add New' ), 'edit_item' => __( 'Edit' ), 'new_item' => __( 'Add New' ), 'view_item' => __( 'View' ), 'search_items' => __( 'Search' ), 'not_found' => __( 'No posts found' ), 'not_found_in_trash' => __( 'No posts found in trash' ) ), 'menu_icon' => 'dashicons-testimonial', 'public' => true, 'has_archive' => true, 'supports' => array( 'title', 'thumbnail', 'editor' ), 'capability_type' => 'post', 'rewrite' => array("slug" => "story"), // Permalinks format // 'menu_position' => 5, ) ); } // Registers a new post type for the poll add_action( 'init', 'register_survey_post' ); function register_survey_post() { register_post_type( 'survey', array( 'labels' => array( 'name' => __( 'Surveys' ), 'singular_name' => __( 'Survey' ), 'add_new' => __( 'Add New' ), 'add_new_item' => __( 'Add New' ), 'edit_item' => __( 'Edit' ), 'new_item' => __( 'Add New' ), 'view_item' => __( 'View' ), 'search_items' => __( 'Search' ), 'not_found' => __( 'No posts found' ), 'not_found_in_trash' => __( 'No posts found in trash' ) ), 'menu_icon' => 'dashicons-chart-bar', 'public' => true, 'has_archive' => true, 'supports' => array( 'title'), 'capability_type' => 'post', 'rewrite' => array("slug" => "story"), // Permalinks format // 'menu_position' => 5, ) ); } ?>
'survey', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '0'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?>

'insta_team', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '0'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> ID) );?>
'post', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '0'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?>

Meyers of the Month:


Read More
'aktt_tweet', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '0'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> 'story', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '0'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?>

'insta_team', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '1'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> ID) );?>
'insta_team', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '2'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> ID) );?>
'post', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '1'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?>

Meyers of the Month:


Read More
'aktt_tweet', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '1'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?>

Make Meyers history.Share. Explore. Engage.

Visit forums
'aktt_tweet', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '2'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> 'story', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '1'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?>

-

Get Involved!

Tag your Instagram* photos with #meyersmovement or #meyersaircraft.

Follow us on Twitter *Your Instagram account must be public for images to appear on website.
'insta_team', 'posts_per_page' => 1, 'order' => 'DEC', 'offset' => '3'); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> ID) );?>