Bradford
Forum Replies Created
-
Forum: Plugins
In reply to: [Multisite Shared Menu] This plugin breaks the WP admin bar.I had to make some more changes and forgot to update, here you go:
<?php // allow this plugin to access functions from WP core before they would normally be avalible require_once( ABSPATH . 'wp-includes/pluggable.php' ); //Brad's hack class MasterSharedMenu { protected $loader; protected $plugin_name; protected $version; protected $current_blog_id; //Brad's hack public function __construct() { $this->plugin_name = 'multisitesharedmenu'; $this->version = '1.2'; $this->current_blog_id = get_current_blog_id(); //Brad's hack $this->define_admin_hooks(); $this->define_public_hooks(); } private function define_admin_hooks() { $this->add_mfs_menu(); } private function define_public_hooks() { add_action( 'plugins_loaded', array( $this, 'check_if_user_logged_in' ) ); //Brad's hack add_filter( 'pre_wp_nav_menu' , array( $this, 'menuswitch_check'), 10, 2 ); add_filter( 'wp_nav_menu_items', array( $this, 'check_restore_blog_menu' ), 10, 2 ); if ( $this->check_if_user_logged_in() ) { //Brad's hack add_filter( 'show_admin_bar', array( $this, 'check_restore_blog_menu' ) ); //Brad's hack } //Brad's hack } public function check_if_user_logged_in() { //Brad's hack return is_user_logged_in(); //Brad's hack } //Brad's hack // Checks if options set to switch menu. If so, switch to the appropriate site and change the menu to load the desired menu.... public function menuswitch_check( $a, $menu_object ) { if( ! ( $mfsSettings = $this->validate_mfs_set() ) ) { return false; } $navigation_affected = $mfsSettings['destinationMenuLocation']; if( !is_array( $navigation_affected ) ) { $navigation_affected = array( $navigation_affected ); // backwards-compatibility } // nav menus now stored as an array, loop through each item foreach ( $navigation_affected as $menu ) { if ( isset( $menu_object ) ) { if( $menu == $menu_object->theme_location ) { $switchSite = get_blog_details( $mfsSettings['sourceSiteID'] ); switch_to_blog( $switchSite->blog_id ); } } } return; } // Switch back to the current blog/site if plugin settings were used. public function check_restore_blog_menu( $items = null, $args = null ) { //Brad's hack switch_to_blog( $this->current_blog_id ); //Brad's hack if ( null != $items ) { //Brad's hack return $items; } //Brad's hack else { //Brad's hack return true; //Brad's hack } //Brad's hack }
Forum: Plugins
In reply to: [Multisite Shared Menu] This plugin breaks the WP admin bar.I fixed your plugin. You’ll see my edits below:
class MasterSharedMenu { protected $loader; protected $plugin_name; protected $version; protected $current_blog_id; //Brad's hack public function __construct() { $this->plugin_name = 'multisitesharedmenu'; $this->version = '1.2'; $this->current_blog_id = get_current_blog_id(); //Brad's hack $this->define_admin_hooks(); $this->define_public_hooks(); } private function define_admin_hooks() { $this->add_mfs_menu(); } private function define_public_hooks() { add_filter( 'pre_wp_nav_menu' , array( $this, 'menuswitch_check'), 10, 2 ); add_filter( 'show_admin_bar', array( $this, 'check_restore_blog_menu' ) ); //Brad's hack } // Checks if options set to switch menu. If so, switch to the appropriate site and change the menu to load the desired menu.... public function menuswitch_check( $a, $menu_object ) { if( !( $mfsSettings = $this->validate_mfs_set() )) { return false; } $navigation_affected = $mfsSettings['destinationMenuLocation']; if( !is_array( $navigation_affected ) ) { $navigation_affected = array( $navigation_affected ); // backwards-compatibility } // nav menus now stored as an array, loop through each item foreach ( $navigation_affected as $menu) { if (isset( $menu_object )) { if( $menu == $menu_object->theme_location ) { $switchSite = get_blog_details($mfsSettings['sourceSiteID']); switch_to_blog($switchSite->blog_id); } } } return; } // Switch back to the current blog/site if plugin settings were used. public function check_restore_blog_menu() {//Brad's hack switch_to_blog($this->current_blog_id); //Brad's hack return true;//Brad's hack }
Forum: Fixing WordPress
In reply to: I can't login to the dashboardHi,
Sounds like you had a login page setup on the front-end of your WP site. Have you tried going to the default login page?
yoursiteurl.com/wp-login.php or yoursiteurl.com/wp-admin
Forum: Fixing WordPress
In reply to: Display list of child pages published in the current month onlyGlad to hear it worked for you!
Can you please mark this topic as resolved?
Thanks!
Forum: Fixing WordPress
In reply to: Display list of child pages published in the current month onlyI had to make a small change to the code I gave you because it was still loading pages that weren’t in the current month.
Change was to the arguments:
$args = array ( 'post_type' => 'page', 'post_parent' => $post->ID, 'year' => $year, 'monthnum' => $month, 'posts_per_page' => -1 );
‘monthnum’ => $month,
Forum: Fixing WordPress
In reply to: Display list of child pages published in the current month onlyI just tested the code I supplied above and it worked as expected. Did you replace the “$parent_page_id” variable with your own?
I added this code to one of my site’s page.php and replaced $parent_page_id with $post->ID.
If you are loading this code outside the loop, try using get_the_ID() to get the current page ID.
Forum: Fixing WordPress
In reply to: Display list of child pages published in the current month onlyI’m not 100% sure what your asking about regarding running the code on a widget. Did you create your own widget and try to use my code in it?
If nothing is loading after your header, there is most likely a PHP error. Check your error logs or turn on error displaying.
I can test, the code I supplied quick and see if there is an error with it.
Forum: Fixing WordPress
In reply to: Display list of child pages published in the current month onlyHello,
Instead of using wp_list_page(), I would try using WP_Query().
Here is an example of how to accomplish this:
$year = date('Y'); $month = date('m'); $args = array ( 'post_type' => 'page', 'post_parent' => $parent_page_id, 'year' => $year, 'month' => $month, 'posts_per_page' => -1 ); $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() ) { echo '<ul>'; while ( $query->have_posts() ) { $query->the_post(); echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>'; } echo '</ul>'; } else { // no posts found } /* Restore original Post Data */ wp_reset_postdata();
I did not test this code, but it should get you on the right track.
-Brad
Forum: Plugins
In reply to: [Page Restrict] Restrict woocommerce shop pageI was faced with this problem today.
Here was my solution:
<?php //Add this to the top of your header.php file (in your theme). By: Bradford Nelson //Check if user is not logged in if ( !is_user_logged_in() ) { $url_uri = $_SERVER['REQUEST_URI']; //redirect shop page. if ( $url_uri == '/shop/' ) { wp_redirect( home_url( '/restricted' ) ); } } ?>
Note* you can change the ‘/restricted’ to any page slug you want, or just use home_url() to redirect to the home page.
If that is the case, you should change the wording below the field.
“The format of of the text appearing in the balloon describing the location. This accepts Event Related Placeholders and Location Related Placeholders placeholders.”
Single Location/Event Map Format:
<strong>#_LOCATIONNAME</strong><br> #_LOCATIONADDRESS - #_LOCATIONTOWN<br> #_EVENTDATES<br> #_EVENTTIMES
event-single.php template override:
<?php global $EM_Event; /* @var $EM_Event EM_Event */ <div class="EventMap"> <?php echo $EM_Event->output('#_LOCATIONMAP'); ?><BR> </div> <!-- LAYOUT ONE - IF EVENT HAS BOOKING --> <?php if (get_post_meta($EM_Event->ID, '_event_rsvp', true) == 1) { ?> <div class="EventContent"> <!--<p> <strong>Date/Time</strong><br/> <?php //echo $EM_Event->output('#_EVENTDATES'); ?><br /> <i><?php //echo $EM_Event->output('#_EVENTTIMES'); ?></i> </p>--> <?php echo $EM_Event->output('#_EVENTNOTES'); ?> <div class="EventBookingsForm" > <h3>Bookings</h3> <?php echo $EM_Event->output('#_BOOKINGFORM'); ?> </div> </div> <?php if( have_rows('sponsors') ): ?> <div class="EventSponsors"> <h3 id="EventSponsors" >Event Sponsors</h3> <?php $the_sponsors = array(); while( have_rows('sponsors') ): the_row(); // vars $sponsor_level = get_sub_field('sponsorship_level'); $get_sponsor = get_sub_field('select_sponsors'); $the_sponsors[$sponsor_level] = $get_sponsor; endwhile; //print_r($the_sponsors); foreach( $the_sponsors AS $level=>$sponsors ): echo '<h3 class="SponsorLevel">'.$level.'</h3>'; echo '<ul class="SponsorList">'; foreach( $sponsors AS $sponsor ): //post vars $sponsor_image = get_post_meta($sponsor->ID, "sponsors_logo", true); $alt_text = get_post_meta($sponsor_image, '_wp_attachment_image_alt', true); $size = "thumbnail"; // (thumbnail, medium, large, full or custom size) $image = wp_get_attachment_image_src( $sponsor_image, $size ); $link = get_post_meta($sponsor->ID, "sponsors_site", true); ?> <li> <p><a href="<?php echo $link ?>"><img src="<?php echo $image[0]; ?>" alt="<?php if($alt_text){ echo $alt_text; }else{ echo $sponsor->post_title; }?>" /></a></p> </li> <?php endforeach; echo '</ul>'; echo '<div class="ClearFix"></div>'; endforeach; ?> </div> <?php endif; ?> <?php }else { ?> <!-- LAYOUT TWO - IF EVENT DOES NOT HAVE BOOKING --> <div class="EventContent"> <!--<p> <strong>Date/Time</strong><br/> <?php //echo $EM_Event->output('#_EVENTDATES'); ?><br /> <i><?php //echo $EM_Event->output('#_EVENTTIMES'); ?></i> </p>--> <?php echo $EM_Event->output('#_EVENTNOTES'); ?> </div> <?php if( have_rows('sponsors') ): ?> <div class="EventSponsors" > <h3 id="EventSponsors" >Event Sponsors</h3> <?php $the_sponsors = array(); while( have_rows('sponsors') ): the_row(); // vars $sponsor_level = get_sub_field('sponsorship_level'); $get_sponsor = get_sub_field('select_sponsors'); $the_sponsors[$sponsor_level] = $get_sponsor; endwhile; //print_r($the_sponsors); foreach( $the_sponsors AS $level=>$sponsors ): echo '<h3 class="SponsorLevel">'.$level.'</h3>'; echo '<ul class="SponsorList">'; foreach( $sponsors AS $sponsor ): //post vars $sponsor_image = get_post_meta($sponsor->ID, "sponsors_logo", true); $alt_text = get_post_meta($sponsor_image, '_wp_attachment_image_alt', true); $size = "thumbnail"; // (thumbnail, medium, large, full or custom size) $image = wp_get_attachment_image_src( $sponsor_image, $size ); $link = get_post_meta($sponsor->ID, "sponsors_site", true); ?> <li> <p><a href="<?php echo $link ?>"><img src="<?php echo $image[0]; ?>" alt="<?php if($alt_text){ echo $alt_text; }else{ echo $sponsor->post_title; }?>" /></a></p> </li> <?php endforeach; echo '</ul>'; echo '<div class="ClearFix"></div>'; endforeach; ?> </div> <?php endif; ?> <?php } ?>
Yes it is possible, you’ll have edit one of the theme files to do so.
FYI, this post is probably more appropriate for the “Themes and Templates” forums.
Forum: Fixing WordPress
In reply to: Help With The FAQ PageGlad to be of help!
Forum: Fixing WordPress
In reply to: Help With The FAQ PageHi there,
I took a quick peek and made a change.
Try this:
get_header(); $paged= get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; ?> <div class="content"> <div class="main_section"> <div class="content_left"> <?php while ( have_posts() ) : the_post(); ?> <h1><?php the_title();?></h1> <?php the_content();?> <?php endwhile; // end of the loop. ?> <?php $questions_query = $wp_questions_query; $wp_questions_query = null; $wp_questions_query = new WP_Query( array ( 'showposts' => '10', 'paged' => $paged, 'post_type' => 'questions', 'orderby' => 'menu_order', 'order' => 'ASC') ); ?> <?php if($wp_questions_query->have_posts()) : $faqindex = 0; ?> <?php while ($wp_questions_query->have_posts()) : $wp_questions_query->the_post(); $imageArray = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full'); $imageURL = $imageArray[0]; $faqindex++; /*Change was here by: Brad Nelson*/ $cls = 'none'; $img = 'plus_pic.jpg'; /*End of change*/ ?> <div class="blog_headingpart"> <h4 class="font14 green" style="padding-bottom:0px;"><span class="black">Q<?php echo $faqindex;?>)</span><?php the_title();?></h4> <div id="detail_id<?php echo $faqindex;?>" style="display:<?php echo $cls;?>; padding-top:8px;"> <div class="faq_uqestionpart"> <?php the_content();?> </div> </div> <div class="right" onclick="toggleDiv('detail_id<?php echo $faqindex;?>','conrtol_id<?php echo $faqindex;?>')"><a href="javascript:void(0)"><img src="<?php echo get_template_directory_uri(); ?>/images/<?php echo $img;?>" alt="" id="conrtol_id<?php echo $faqindex;?>" /></a></div> <div class="clear"></div> </div> <?php endwhile; ?> <?php if(function_exists('wp_pagenavi')) { ?> <?php wp_pagenavi( array( 'query' => $wp_questions_query ) ); ?> <?php } ?> <?php else : ?> <?php echo "No Records Found"; ?> <?php endif; ?> <?php $wp_questions_query = null; $wp_questions_query = $questions_query; wp_reset_postdata(); ?> <div class="clear"></div> </div> <?php get_sidebar();?> <div class="clear"></div> </div> </div>
Let me know if this works!
Forum: Fixing WordPress
In reply to: PDF in WordPressHi there,
The problem isn’t with WordPress, but with your hosting. Depending on where you are hosting the site, you should be able to change the upload limit.
You will need to locate a file named php.ini in your WP installation directory on the web server. If it does not exist, create one.
Edit or add the following:
upload_max_filesize = 25m
post_max_size = 25mChange the 25m to whatever limit you want to set, I find 25m is enough in most of my cases.
You many have to edit or add the max_execution_time too, so a larger file has time to finish uploading. Example:
max_execution_time = 1000Also, you may need to increase WordPress’s memory limit depending on the limit you set in your php.ini file. Lets say you make the upload limit 60m, you’ll need to add this line to your wp-config.php file:
define(‘WP_MEMORY_LIMIT’, ’64M’);
(I like to add a little extra from what you set the upload limit to)Hope this helps.