// Create shortcode for year displayed in footer. Use in Customize->Footer Settings->Edit the footer content e.g. [year]
function footerYear() {
- $date = date('Y');
- return '<span>'.$date.'</span>' ;
+ $date = date('Y');
+ return '<span>'.$date.'</span>' ;
}
add_shortcode('year', 'footerYear');
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
- // Get the Post ID.
- $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
- if( !isset( $post_id ) ) return;
- // Hide the editor on the page titled 'Homepage'
- $homepgname = get_the_title($post_id);
- if($homepgname == 'Homepage'){
- remove_post_type_support('page', 'editor');
- }
- // Hide the editor on a page with a specific page template
- // Get the name of the Page Template file.
- $template_file = get_post_meta($post_id, '_wp_page_template', true);
- if($template_file == 'front-page.php'){ // the filename of the page template
- remove_post_type_support('page', 'editor');
- }
+ // Get the Post ID.
+ $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
+ if( !isset( $post_id ) ) return;
+ // Hide the editor on the page titled 'Homepage'
+ $homepgname = get_the_title($post_id);
+ if($homepgname == 'Homepage'){
+ remove_post_type_support('page', 'editor');
+ }
+ // Hide the editor on a page with a specific page template
+ // Get the name of the Page Template file.
+ $template_file = get_post_meta($post_id, '_wp_page_template', true);
+ if($template_file == 'front-page.php'){ // the filename of the page template
+ remove_post_type_support('page', 'editor');
+ }
}
// Choose random slide number, excluding specific slide ID's
function randWithout() {
- do {
- $n = rand(1,3);
- }
- while(in_array($n, array(2)));
- return $n;
+ do {
+ $n = rand(1,3);
+ }
+ while(in_array($n, array(2)));
+ return $n;
}
// Clean up the_excerpt()
function excerpt_more() {
- return ' … <a href="' . get_permalink() . '">' . __('Read More ►', 'sage') . '</a>';
+ return ' … <a href="' . get_permalink() . '">' . __('Read More ►', 'sage') . '</a>';
}
add_filter('excerpt_more', __NAMESPACE__ . '\\excerpt_more');
function custom_excerpt_length( $length ) {
- return 30;
+ return 30;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
// Change admin side menu, Posts --> News
function change_post_menu_label() {
- global $menu;
- global $submenu;
- $menu[5][0] = 'News';
- $submenu['edit.php'][5][0] = 'News';
- $submenu['edit.php'][10][0] = 'Add News';
- $submenu['edit.php'][16][0] = 'News Tags';
- echo '';
+ global $menu;
+ global $submenu;
+ $menu[5][0] = 'News';
+ $submenu['edit.php'][5][0] = 'News';
+ $submenu['edit.php'][10][0] = 'Add News';
+ $submenu['edit.php'][16][0] = 'News Tags';
+ echo '';
}
function change_post_object_label() {
- global $wp_post_types;
- $labels = &$wp_post_types['post']->labels;
- $labels->name = 'News';
- $labels->singular_name = 'News Item';
- $labels->add_new = 'Add News Item';
- $labels->add_new_item = 'Add News Item';
- $labels->edit_item = 'Edit News';
- $labels->new_item = 'News';
- $labels->view_item = 'View News';
- $labels->search_items = 'Search News';
- $labels->not_found = 'No News found';
- $labels->not_found_in_trash = 'No News found in Trash';
+ global $wp_post_types;
+ $labels = &$wp_post_types['post']->labels;
+ $labels->name = 'News';
+ $labels->singular_name = 'News Item';
+ $labels->add_new = 'Add News Item';
+ $labels->add_new_item = 'Add News Item';
+ $labels->edit_item = 'Edit News';
+ $labels->new_item = 'News';
+ $labels->view_item = 'View News';
+ $labels->search_items = 'Search News';
+ $labels->not_found = 'No News found';
+ $labels->not_found_in_trash = 'No News found in Trash';
}
add_action( 'init', 'change_post_object_label' );
add_action( 'admin_menu', 'change_post_menu_label' );
// Filters blank search query so results are not found instead of going to the home page
function SearchFilter($query) {
- // If 's' request variable is set but empty
- if (isset($_GET['s']) && empty($_GET['s']) && $query->is_main_query()){
- $query->is_search = true;
- $query->is_home = false;
- }
- return $query;
+ // If 's' request variable is set but empty
+ if (isset($_GET['s']) && empty($_GET['s']) && $query->is_main_query()){
+ $query->is_search = true;
+ $query->is_home = false;
+ }
+ return $query;
}
add_filter('pre_get_posts','SearchFilter');
// Exclude pages from search queries
function exclude_pages_search_when_logged_in($query) {
- if ( $query->is_search )
- $query->set( 'post__not_in', array( 22,24,26,28 ) );
+ if ( $query->is_search )
+ $query->set( 'post__not_in', array( 22,24,26,28 ) );
- return $query;
+ return $query;
}
add_filter( 'pre_get_posts', 'exclude_pages_search_when_logged_in' );
/*
function change_wp_search_size($query) {
- if ( $query->is_search ) // Make sure it is a search page
- $query->query_vars['posts_per_page'] = -1; // Change 10 to the number of posts you would like to show
+ if ( $query->is_search ) // Make sure it is a search page
+ $query->query_vars['posts_per_page'] = -1; // Change 10 to the number of posts you would like to show
- return $query; // Return our modified query variables
+ return $query; // Return our modified query variables
}
add_filter('pre_get_posts', 'change_wp_search_size'); // Hook our custom function onto the request filter
*/
function display_memberfindme_directory() {
- // Show MemberFindMe shortcode from Directory page
+ // Show MemberFindMe shortcode from Directory page
//$_REQUEST['textSearch'] = $_REQUEST['s'];
$_REQUEST['action'] = 'list';
- $_REQUEST['event_name'] = $_REQUEST['s'];
- echo do_shortcode('[glm-members-list view="grid" ]');
- if( isset($_REQUEST['event_name']) && !empty($_REQUEST['event_name'])){
- echo do_shortcode('[glm-members-event-list]');
- }
- // $my_postid = 30722;//This is page id or post id
- // $content_post = get_post($my_postid);
- // $content = $content_post->post_content;
- // $content = apply_filters('the_content', $content);
- // $content = str_replace(']]>', ']]>', $content);
- // echo $content;
+ $_REQUEST['event_name'] = $_REQUEST['s'];
+ echo do_shortcode('[glm-members-list view="grid"]');
+ if( isset($_REQUEST['event_name']) && !empty($_REQUEST['event_name'])){
+ echo do_shortcode('[glm-members-event-list limit="10"]');
+ echo '<a href="' . get_permalink( 31026 ) . '">View All Events</a>';
+ }
+ // $my_postid = 30722;//This is page id or post id
+ // $content_post = get_post($my_postid);
+ // $content = $content_post->post_content;
+ // $content = apply_filters('the_content', $content);
+ // $content = str_replace(']]>', ']]>', $content);
+ // echo $content;
}
// Custom User Profile settings - Hide bunch of stuff
function hide_personal_options(){
- if (!current_user_can('manage_options')) {
- echo "\n" . '<script type="text/javascript">
- jQuery(document).ready(function($) {
- $(\'form#your-profile > h2:nth-of-type(1)\').hide();
- $(\'form#your-profile > table:nth-of-type(1)\').hide();
- $(\'form#your-profile > h2:nth-of-type(2)\').hide();
- $(\'form#your-profile > table:nth-of-type(2)\').hide();
- $(\'form#your-profile > h2:nth-of-type(3)\').hide();
- $(\'form#your-profile > table:nth-of-type(3)\').hide();
- $(\'form#your-profile > h2:nth-of-type(4)\').hide();
- $(\'form#your-profile > table:nth-of-type(4)\').hide();
- $(\'form#your-profile > h2:nth-of-type(5)\').hide();
- $(\'form#your-profile > table:nth-of-type(5)\').hide();
- $(\'form#your-profile > h2:nth-of-type(6)\').hide();
- $(\'form#your-profile > table:nth-of-type(6)\').hide();
- $(\'form#your-profile > h3:nth-of-type(1)\').hide();
-
- //$(\'form#your-profile > table:nth-of-type(6) tr:nth-of-type(2)\').hide();
-
- $(\'form#your-profile\').show();
-
- // hides extra buttons from reports/exports plugin
- $(\'.actions .button:nth-of-type(2)\').hide();
- $(\'.actions .button:nth-of-type(3)\').hide();
- $(\'.actions .button:nth-of-type(4)\').hide();
- });
- </script>' . "\n";
- }
+ if (!current_user_can('manage_options')) {
+ echo "\n" . '<script type="text/javascript">
+ jQuery(document).ready(function($) {
+ $(\'form#your-profile > h2:nth-of-type(1)\').hide();
+ $(\'form#your-profile > table:nth-of-type(1)\').hide();
+ $(\'form#your-profile > h2:nth-of-type(2)\').hide();
+ $(\'form#your-profile > table:nth-of-type(2)\').hide();
+ $(\'form#your-profile > h2:nth-of-type(3)\').hide();
+ $(\'form#your-profile > table:nth-of-type(3)\').hide();
+ $(\'form#your-profile > h2:nth-of-type(4)\').hide();
+ $(\'form#your-profile > table:nth-of-type(4)\').hide();
+ $(\'form#your-profile > h2:nth-of-type(5)\').hide();
+ $(\'form#your-profile > table:nth-of-type(5)\').hide();
+ $(\'form#your-profile > h2:nth-of-type(6)\').hide();
+ $(\'form#your-profile > table:nth-of-type(6)\').hide();
+ $(\'form#your-profile > h3:nth-of-type(1)\').hide();
+
+ //$(\'form#your-profile > table:nth-of-type(6) tr:nth-of-type(2)\').hide();
+
+ $(\'form#your-profile\').show();
+
+ // hides extra buttons from reports/exports plugin
+ $(\'.actions .button:nth-of-type(2)\').hide();
+ $(\'.actions .button:nth-of-type(3)\').hide();
+ $(\'.actions .button:nth-of-type(4)\').hide();
+ });
+ </script>' . "\n";
+ }
}
// add_action('admin_head','hide_personal_options');
function modify_contact_methods($profile_fields) {
- // Remove Social Media fields added by Yoast SEO
- unset($profile_fields['facebook']);
- unset($profile_fields['twitter']);
- unset($profile_fields['googleplus']);
- unset($profile_fields['first_name']);
+ // Remove Social Media fields added by Yoast SEO
+ unset($profile_fields['facebook']);
+ unset($profile_fields['twitter']);
+ unset($profile_fields['googleplus']);
+ unset($profile_fields['first_name']);
- return $profile_fields;
+ return $profile_fields;
}
add_filter('user_contactmethods', 'modify_contact_methods');
//
function my_show_extra_profile_fields( $user ) {
- ?>
+ ?>
- <table class="form-table">
+ <table class="form-table">
- <tr>
- <th>
- <input class="button" type="button" onclick="location.href='<?php echo esc_url( home_url( '/sign-in/' ) ); ?>';" value="Return to Editing Your Profile" />
- </th>
- </tr>
+ <tr>
+ <th>
+ <input class="button" type="button" onclick="location.href='<?php echo esc_url( home_url( '/sign-in/' ) ); ?>';" value="Return to Editing Your Profile" />
+ </th>
+ </tr>
- </table>
+ </table>
- <!-- Additional Add Events button
- <table class="form-table">
+ <!-- Additional Add Events button
+ <table class="form-table">
- <tr>
- <th>
- <h3>Post an Event</h3>
- <input class="button" type="button" onclick="location.href='<?php// echo esc_url( home_url( '/events/add-an-event/' ) ); ?>';" value="Post an Event" />
- </th>
- </tr>
+ <tr>
+ <th>
+ <h3>Post an Event</h3>
+ <input class="button" type="button" onclick="location.href='<?php// echo esc_url( home_url( '/events/add-an-event/' ) ); ?>';" value="Post an Event" />
+ </th>
+ </tr>
- </table>
- -->
+ </table>
+ -->
- <table class="form-table">
+ <table class="form-table">
- <tr>
- <th>
- <input class="button" type="button" onclick="location.href='<?php echo esc_url( home_url( '/about-wmta/submit-a-special/' ) ); ?>';" value="Submit Special or Package to WMTA" />
- </th>
- </tr>
+ <tr>
+ <th>
+ <input class="button" type="button" onclick="location.href='<?php echo esc_url( home_url( '/about-wmta/submit-a-special/' ) ); ?>';" value="Submit Special or Package to WMTA" />
+ </th>
+ </tr>
- </table>
+ </table>
- <table class="form-table">
+ <table class="form-table">
- <tr>
- <th>
- <h4>Your Member URL</h4>
- <p><?php global $current_user; get_currentuserinfo();echo get_author_posts_url( $current_user->ID ).'#!biz/id/'.$current_user->user_login; ?></p>
+ <tr>
+ <th>
+ <h4>Your Member URL</h4>
+ <p><?php global $current_user; get_currentuserinfo();echo get_author_posts_url( $current_user->ID ).'#!biz/id/'.$current_user->user_login; ?></p>
- <p><input class="button goToURL" type="button" value="View Profile" /></p>
- </th>
- </tr>
+ <p><input class="button goToURL" type="button" value="View Profile" /></p>
+ </th>
+ </tr>
- </table>
+ </table>
- <script type="text/javascript">
- jQuery(".goToURL").on("click",function(){
- window.open('<?php global $current_user; get_currentuserinfo();echo get_author_posts_url( $current_user->ID ).'#!biz/id/'.$current_user->user_login; ?>','_blank');
- });
- jQuery(window).bind("load", function() {
- jQuery('h1').html('Members, Add Your Events & Header Image Here');
- });
- </script>
+ <script type="text/javascript">
+ jQuery(".goToURL").on("click",function(){
+ window.open('<?php global $current_user; get_currentuserinfo();echo get_author_posts_url( $current_user->ID ).'#!biz/id/'.$current_user->user_login; ?>','_blank');
+ });
+ jQuery(window).bind("load", function() {
+ jQuery('h1').html('Members, Add Your Events & Header Image Here');
+ });
+ </script>
// Exclude categories from categories widget
function exclude_widget_categories($args){
- $exclude = "665,1"; // The IDs of the excluding categories
- $args["exclude"] = $exclude;
- return $args;
+ $exclude = "665,1"; // The IDs of the excluding categories
+ $args["exclude"] = $exclude;
+ return $args;
}
add_filter("widget_categories_args","exclude_widget_categories");
* @return string
*/
function filterEventOutputCondition($replacement, $condition, $match, $EM_Event){
- if (is_object($EM_Event)) {
+ if (is_object($EM_Event)) {
- switch ($condition) {
+ switch ($condition) {
- // #_ATT{Event Cost}
- case 'has_att_cost':
- if (is_array($EM_Event->event_attributes) && !empty($EM_Event->event_attributes['Event Cost']))
- $replacement = preg_replace('/\{\/?has_att_cost\}/', '', $match);
- else
- $replacement = '';
- break;
+ // #_ATT{Event Cost}
+ case 'has_att_cost':
+ if (is_array($EM_Event->event_attributes) && !empty($EM_Event->event_attributes['Event Cost']))
+ $replacement = preg_replace('/\{\/?has_att_cost\}/', '', $match);
+ else
+ $replacement = '';
+ break;
- }
+ }
- }
+ }
- return $replacement;
+ return $replacement;
}
add_filter('em_event_output_condition', 'filterEventOutputCondition', 10, 4);
// Add custom column to users admin columns
function new_modify_user_table_displayname( $column ) {
- $column['display_name'] = 'Display Name';
- return $column;
+ $column['display_name'] = 'Display Name';
+ return $column;
}
add_filter( 'manage_users_columns', 'new_modify_user_table_displayname' );
function new_modify_user_table_row_displayname( $val, $column_name, $user_id ) {
- $user = get_userdata( $user_id );
- switch ($column_name) {
- case 'display_name' :
- return get_the_author_meta( 'display_name', $user_id );
- break;
- default:
- }
- return $return;
+ $user = get_userdata( $user_id );
+ switch ($column_name) {
+ case 'display_name' :
+ return get_the_author_meta( 'display_name', $user_id );
+ break;
+ default:
+ }
+ return $return;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row_displayname', 10, 3 );
add_action ('admin_head','make_display_name_f_name_last_name');
function make_display_name_f_name_last_name(){
-// $users = get_users(array('fields'=>'all'));
+// $users = get_users(array('fields'=>'all'));
//
-// foreach($users as $user){
-// $user = get_userdata($user->ID);
+// foreach($users as $user){
+// $user = get_userdata($user->ID);
//
-// $display_name = $user->nickname;
+// $display_name = $user->nickname;
//
-// if($display_name!=' ') wp_update_user( array ('ID' => $user->ID, 'display_name' => $display_name) );
-// else wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
+// if($display_name!=' ') wp_update_user( array ('ID' => $user->ID, 'display_name' => $display_name) );
+// else wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
//
-// if($user->display_name == '')
-// wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
-// }
+// if($user->display_name == '')
+// wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
+// }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
add_action( 'dashboard_glance_items', 'cpad_at_glance_content_table_end' );
function cpad_at_glance_content_table_end()
{
- $args = array(
- //'public' => true,
- '_builtin' => false
- );
- $output = 'object';
- $operator = 'and';
-
- $post_types = get_post_types($args, $output, $operator);
- foreach ($post_types as $post_type) {
- $num_posts = wp_count_posts($post_type->name);
- $num = number_format_i18n($num_posts->publish);
- $text = _n($post_type->labels->singular_name, $post_type->labels->name, intval($num_posts->publish));
- if (current_user_can('edit_posts')) {
- $output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $num . ' ' . $text . '</a>';
- echo '<li class="post-count ' . $post_type->name . '-count">' . $output . '</li>';
- } else {
- $output = '<span>' . $num . ' ' . $text . '</span>';
- echo '<li class="post-count ' . $post_type->name . '-count">' . $output . '</li>';
- }
- }
+ $args = array(
+ //'public' => true,
+ '_builtin' => false
+ );
+ $output = 'object';
+ $operator = 'and';
+
+ $post_types = get_post_types($args, $output, $operator);
+ foreach ($post_types as $post_type) {
+ $num_posts = wp_count_posts($post_type->name);
+ $num = number_format_i18n($num_posts->publish);
+ $text = _n($post_type->labels->singular_name, $post_type->labels->name, intval($num_posts->publish));
+ if (current_user_can('edit_posts')) {
+ $output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $num . ' ' . $text . '</a>';
+ echo '<li class="post-count ' . $post_type->name . '-count">' . $output . '</li>';
+ } else {
+ $output = '<span>' . $num . ' ' . $text . '</span>';
+ echo '<li class="post-count ' . $post_type->name . '-count">' . $output . '</li>';
+ }
+ }
}
//Users Can only see their own media library files
add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments', 10, 1 );
function show_current_user_attachments( $query = array() ) {
- $user_id = get_current_user_id();
- if( $user_id ) {
- $query['author'] = $user_id;
- }
- return $query;
+ $user_id = get_current_user_id();
+ if( $user_id ) {
+ $query['author'] = $user_id;
+ }
+ return $query;
}
function filter_cpt_listing( $wp_query_obj )
{
- // Front end, do nothing
- if( !is_admin() )
- return;
+ // Front end, do nothing
+ if( !is_admin() )
+ return;
- global $current_user, $pagenow;
- get_currentuserinfo();
+ global $current_user, $pagenow;
+ get_currentuserinfo();
- // http://php.net/manual/en/function.is-a.php
- if( !is_a( $current_user, 'WP_User') )
- return;
+ // http://php.net/manual/en/function.is-a.php
+ if( !is_a( $current_user, 'WP_User') )
+ return;
- // Not the correct screen, bail out
- if( 'edit.php' != $pagenow )
- return;
+ // Not the correct screen, bail out
+ if( 'edit.php' != $pagenow )
+ return;
- // Not the correct post type, bail out
- if( 'event' != $wp_query_obj->query['post_type'] )
- return;
+ // Not the correct post type, bail out
+ if( 'event' != $wp_query_obj->query['post_type'] )
+ return;
- // If the user is not administrator, filter the post listing
- if( !current_user_can( 'delete_plugins' ) )
- $wp_query_obj->set('author', $current_user->ID );
+ // If the user is not administrator, filter the post listing
+ if( !current_user_can( 'delete_plugins' ) )
+ $wp_query_obj->set('author', $current_user->ID );
}
add_action( 'pre_get_posts', 'filter_cpt_listing_er' );
function filter_cpt_listing_er( $wp_query_obj )
{
- // Front end, do nothing
- if( !is_admin() )
- return;
+ // Front end, do nothing
+ if( !is_admin() )
+ return;
- global $current_user, $pagenow;
- get_currentuserinfo();
+ global $current_user, $pagenow;
+ get_currentuserinfo();
- // http://php.net/manual/en/function.is-a.php
- if( !is_a( $current_user, 'WP_User') )
- return;
+ // http://php.net/manual/en/function.is-a.php
+ if( !is_a( $current_user, 'WP_User') )
+ return;
- // Not the correct screen, bail out
- if( 'edit.php' != $pagenow )
- return;
+ // Not the correct screen, bail out
+ if( 'edit.php' != $pagenow )
+ return;
- // Not the correct post type, bail out
- if( 'event-recurring' != $wp_query_obj->query['post_type'] )
- return;
+ // Not the correct post type, bail out
+ if( 'event-recurring' != $wp_query_obj->query['post_type'] )
+ return;
- // If the user is not administrator, filter the post listing
- if( !current_user_can( 'delete_plugins' ) )
- $wp_query_obj->set('author', $current_user->ID );
+ // If the user is not administrator, filter the post listing
+ if( !current_user_can( 'delete_plugins' ) )
+ $wp_query_obj->set('author', $current_user->ID );
}
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
- $post_types = get_post_types();
- foreach ($post_types as $post_type) {
- if(post_type_supports($post_type, 'comments')) {
- remove_post_type_support($post_type, 'comments');
- remove_post_type_support($post_type, 'trackbacks');
- }
- }
+ $post_types = get_post_types();
+ foreach ($post_types as $post_type) {
+ if(post_type_supports($post_type, 'comments')) {
+ remove_post_type_support($post_type, 'comments');
+ remove_post_type_support($post_type, 'trackbacks');
+ }
+ }
}
add_action('admin_init', 'df_disable_comments_post_types_support');
// Close comments on the front-end
function df_disable_comments_status() {
- return false;
+ return false;
}
add_filter('comments_open', 'df_disable_comments_status', 20, 2);
add_filter('pings_open', 'df_disable_comments_status', 20, 2);
// Hide existing comments
function df_disable_comments_hide_existing_comments($comments) {
- $comments = array();
- return $comments;
+ $comments = array();
+ return $comments;
}
add_filter('comments_array', 'df_disable_comments_hide_existing_comments', 10, 2);
// Remove comments page in menu
function df_disable_comments_admin_menu() {
- remove_menu_page('edit-comments.php');
+ remove_menu_page('edit-comments.php');
}
add_action('admin_menu', 'df_disable_comments_admin_menu');
// Redirect any user trying to access comments page
function df_disable_comments_admin_menu_redirect() {
- global $pagenow;
- if ($pagenow === 'edit-comments.php') {
- wp_redirect(admin_url()); exit;
- }
+ global $pagenow;
+ if ($pagenow === 'edit-comments.php') {
+ wp_redirect(admin_url()); exit;
+ }
}
add_action('admin_init', 'df_disable_comments_admin_menu_redirect');
// Remove comments metabox from dashboard
function df_disable_comments_dashboard() {
- remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
+ remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
}
add_action('admin_init', 'df_disable_comments_dashboard');
// Remove comments links from admin bar
function df_disable_comments_admin_bar() {
- if (is_admin_bar_showing()) {
- remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
- }
+ if (is_admin_bar_showing()) {
+ remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
+ }
}
add_action('init', 'df_disable_comments_admin_bar');
* - aggregate list of checked checkboxes
* - map multiple conditional fields to a single field so you can refer to the single field for the selected value
*
- * @version 1.1
+ * @version 1.1
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
* @copyright 2014 Gravity Wiz
*/
class GWMapFieldToField {
- public $lead = null;
- function __construct( ) {
- add_filter( 'gform_pre_validation', array( $this, 'map_field_to_field' ), 11 );
- }
- function map_field_to_field( $form ) {
- foreach( $form['fields'] as $field ) {
- if( is_array( $field['inputs'] ) ) {
- $inputs = $field['inputs'];
- } else {
- $inputs = array(
- array(
- 'id' => $field['id'],
- 'name' => $field['inputName']
- )
- );
- }
- foreach( $inputs as $input ) {
- $value = rgar( $input, 'name' );
- if( ! $value )
- continue;
- $post_key = 'input_' . str_replace( '.', '_', $input['id'] );
- $current_value = rgpost( $post_key );
- preg_match_all( '/{[^{]*?:(\d+(\.\d+)?)(:(.*?))?}/mi', $input['name'], $matches, PREG_SET_ORDER );
- // if there is no merge tag in inputName - OR - if there is already a value populated for this field, don't overwrite
- if( empty( $matches ) )
- continue;
- $entry = $this->get_lead( $form );
- foreach( $matches as $match ) {
- list( $tag, $field_id, $input_id, $filters, $filter ) = array_pad( $match, 5, 0 );
- $force = $filter === 'force';
- $tag_field = RGFormsModel::get_field( $form, $field_id );
- // only process replacement if there is no value OR if force filter is provided
- $process_replacement = ! $current_value || $force;
- if( $process_replacement && ! RGFormsModel::is_field_hidden( $form, $tag_field, array() ) ) {
- $field_value = GFCommon::replace_variables( $tag, $form, $entry );
- if( is_array( $field_value ) ) {
- $field_value = implode( ',', array_filter( $field_value ) );
- }
- } else {
- $field_value = '';
- }
- $value = trim( str_replace( $match[0], $field_value, $value ) );
- }
- if( $value ) {
- $_POST[$post_key] = $value;
- }
- }
- }
- return $form;
- }
- function get_lead( $form ) {
- if( ! $this->lead )
- $this->lead = GFFormsModel::create_lead( $form );
- return $this->lead;
- }
+ public $lead = null;
+ function __construct( ) {
+ add_filter( 'gform_pre_validation', array( $this, 'map_field_to_field' ), 11 );
+ }
+ function map_field_to_field( $form ) {
+ foreach( $form['fields'] as $field ) {
+ if( is_array( $field['inputs'] ) ) {
+ $inputs = $field['inputs'];
+ } else {
+ $inputs = array(
+ array(
+ 'id' => $field['id'],
+ 'name' => $field['inputName']
+ )
+ );
+ }
+ foreach( $inputs as $input ) {
+ $value = rgar( $input, 'name' );
+ if( ! $value )
+ continue;
+ $post_key = 'input_' . str_replace( '.', '_', $input['id'] );
+ $current_value = rgpost( $post_key );
+ preg_match_all( '/{[^{]*?:(\d+(\.\d+)?)(:(.*?))?}/mi', $input['name'], $matches, PREG_SET_ORDER );
+ // if there is no merge tag in inputName - OR - if there is already a value populated for this field, don't overwrite
+ if( empty( $matches ) )
+ continue;
+ $entry = $this->get_lead( $form );
+ foreach( $matches as $match ) {
+ list( $tag, $field_id, $input_id, $filters, $filter ) = array_pad( $match, 5, 0 );
+ $force = $filter === 'force';
+ $tag_field = RGFormsModel::get_field( $form, $field_id );
+ // only process replacement if there is no value OR if force filter is provided
+ $process_replacement = ! $current_value || $force;
+ if( $process_replacement && ! RGFormsModel::is_field_hidden( $form, $tag_field, array() ) ) {
+ $field_value = GFCommon::replace_variables( $tag, $form, $entry );
+ if( is_array( $field_value ) ) {
+ $field_value = implode( ',', array_filter( $field_value ) );
+ }
+ } else {
+ $field_value = '';
+ }
+ $value = trim( str_replace( $match[0], $field_value, $value ) );
+ }
+ if( $value ) {
+ $_POST[$post_key] = $value;
+ }
+ }
+ }
+ return $form;
+ }
+ function get_lead( $form ) {
+ if( ! $this->lead )
+ $this->lead = GFFormsModel::create_lead( $form );
+ return $this->lead;
+ }
}
new GWMapFieldToField();
// Make Search results ordered by post date
function results_by_date( $query ) {
- // not an admin page and is the main query
- if ( !is_admin() && $query->is_main_query() ) {
- if ( is_search() ) {
- $query->set( 'orderby', 'date' );
- }
- }
+ // not an admin page and is the main query
+ if ( !is_admin() && $query->is_main_query() ) {
+ if ( is_search() ) {
+ $query->set( 'orderby', 'date' );
+ }
+ }
}
add_action( 'pre_get_posts', 'results_by_date' );
*/
add_filter( 'gform_tabindex', 'gform_tabindexer', 10, 2 );
function gform_tabindexer( $tab_index, $form = false ) {
- $starting_index = 1000; // if you need a higher tabindex, update this number
- if( $form )
- add_filter( 'gform_tabindex_' . $form['id'], 'gform_tabindexer' );
- return GFCommon::$tab_index >= $starting_index ? GFCommon::$tab_index : $starting_index;
+ $starting_index = 1000; // if you need a higher tabindex, update this number
+ if( $form )
+ add_filter( 'gform_tabindex_' . $form['id'], 'gform_tabindexer' );
+ return GFCommon::$tab_index >= $starting_index ? GFCommon::$tab_index : $starting_index;
}
function select_dropdown_cities() {
- global $post;
+ global $post;
- $args = array(
+ $args = array(
- 'post_type' => 'search-city',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name'
- );
- $loop = new WP_Query( $args );
- echo '<select id="xlo" class="chosen-select" data-placeholder="Select a location"><option value="">Search All Locations</option>';
- if ($loop->have_posts())
- {
- while ( $loop->have_posts() ) : $loop->the_post();
+ 'post_type' => 'search-city',
+ 'posts_per_page' => -1,
+ 'order' => 'ASC',
+ 'orderby' => 'name'
+ );
+ $loop = new WP_Query( $args );
+ echo '<select id="xlo" class="chosen-select" data-placeholder="Select a location"><option value="">Search All Locations</option>';
+ if ($loop->have_posts())
+ {
+ while ( $loop->have_posts() ) : $loop->the_post();
- echo '<option value="',the_title(),'">',the_title(),'</option>';
+ echo '<option value="',the_title(),'">',the_title(),'</option>';
- endwhile;
- }
+ endwhile;
+ }
- echo '</select>';
+ echo '</select>';
}
wp_reset_postdata();
add_filter('admin_footer_text', remove_admin_footer_text, 1000);
function remove_admin_footer_text($footer_text =''){
- return '';
+ return '';
}
add_filter('update_footer', remove_admin_footer_upgrade, 1000);
function remove_admin_footer_upgrade($footer_text =''){
- return '';
+ return '';
}