Support

Account

Forum Replies Created

  • The following jQuery snippet will block all days except Friday (I’m using it for a week-ending form).

    You could try returning the day of the week (in this case 5) or the date as a PHP variable from an ACF custom field.

    https://stackoverflow.com/questions/19395558/highlight-disable-specific-days-in-jquery-ui-datepicker shows examples of formatting for specific dates.

    jQuery(document).ready(function() {
    	$datepicker = jQuery('.rdsn-week-ending .hasDatepicker');
    	$datepicker.datepicker( 'option', {
    		beforeShowDay: function(date) {
            	if (date.getDay() == 5) {
                        return [true, ''];
                    } else {
                        return [false, ''];
                    }
        	}
    	});
    });
  • It’s a year later but thought I’d post a solution – was trying to combine the wrong methods, and it’s actually a lot simpler than I’d thought. The issue was knowing how to insert the style select, but I didn’t how it was referred to in ACF arrays.

    1) Find out the names of the toolbar elements for reference later on. In functions.php add the following:

    add_filter( 'acf/fields/wysiwyg/toolbars' , 'my_toolbars'  );
    function my_toolbars( $toolbars )
    {
          echo '< pre >';
    	print_r($toolbars);
          echo '< /pre >';
          die;
    }

    2) Look at the bottom of the WP admin area and copy the array into a text file for future reference. We now know the names of the buttons.

    < pre >Array
    (
        [Full] => Array
            (
                [1] => Array
                    (
                        [0] => formatselect
                        [1] => bold
                        [2] => italic
                        [3] => bullist
                        [4] => numlist
                        [5] => blockquote
                        [6] => alignleft
                        [7] => aligncenter
                        [8] => alignright
                        [9] => link
                        [10] => unlink
                        [12] => spellchecker
                        [14] => wp_adv
                    )
    
                [2] => Array
                    (
                        [0] => styleselect
                        [1] => strikethrough
                        [2] => hr
                        [4] => removeformat
                        [5] => charmap
                        [6] => outdent
                        [7] => indent
                        [8] => undo
                        [9] => redo
                    )
    
                [3] => Array
                    (
                    )
    
                [4] => Array
                    (
                    )
    
            )
    
        [Basic] => Array
            (
                [1] => Array
                    (
                        [0] => bold
                        [1] => italic
                        [2] => underline
                        [3] => blockquote
                        [4] => strikethrough
                        [5] => bullist
                        [6] => numlist
                        [7] => alignleft
                        [8] => aligncenter
                        [9] => alignright
                        [10] => undo
                        [11] => redo
                        [12] => link
                        [13] => unlink
                        [14] => fullscreen
                    )
    
            )
    
    )
    < /pre >

    3) Remove or comment out the code above that displays the button array. Create your new custom toolbar.

    add_filter( 'acf/fields/wysiwyg/toolbars' , 'custom_toolbars'  );
    function custom_toolbars( $toolbars )
    {
    	// Add a new toolbar called "Custom" - only 1 row of buttons
    	$toolbars['Custom' ] = array();
    	$toolbars['Custom' ][1] = array('styleselect','bold','italic');
    	// return $toolbars
    	return $toolbars;
    }
  • @louiswalch – many thanks for this approach. Have updated to only auto-collapse repeaters in the admin area (working in ACF Pro – version 5.6.10)

    function rdsn_acf_repeater_collapse() {
    ?>
    <style id="rdsn-acf-repeater-collapse">.acf-repeater .acf-table {display:none;}</style>
    <script type="text/javascript">
    	jQuery(function($) {
    		$('.acf-repeater .acf-row').addClass('-collapsed');
    		$('#rdsn-acf-repeater-collapse').detach();
    	});
    </script>
    <?php
    }
    add_action('acf/input/admin_head', 'rdsn_acf_repeater_collapse');
  • Hi @james

    Thank you so much – I’m calling this from functions.php so it’s outside the loop. I only need one gallery so didn’t need the foreach wrapped round the $post_objects variable (and so changed $post_object->ID to $post_objects->ID for the ‘gallery’ field.

    function show_page_gallery() {
    global $post;
    $post_objects = get_field('gallery_select',$post->ID);
    if( $post_objects ):
    	$images = get_field('gallery',$post_objects->ID);
    	if( $images ):
    		foreach( $images as $image ):
    			echo '<img src="'.$image['url'].'" />';
    		endforeach;
    	endif;
    endif;
    }

    The example above is much simplified but works. I’ve now added back all the HTML required to wrap and style the gallery images and it’s displaying perfectly.

    Thanks again.

  • Many thanks holblin – the temporary fix makes life a lot easier when populating a site. Turning the screen options back on for lots of custom fields was driving me nuts. Page Attributes are still disappearing though – dang…

  • I have a similar issue having just updated to 5.1.1. I have a banner gallery assigned to every page using a Repeater Field with a fallback to the gallery assigned to the home page if no images have been uploaded to the individual page.

    If I add and then delete images from a page gallery (have_rows()) appears to still be returning true even though images are no longer assigned to the page and I’ve removed the row(s) from the admin area (and saved the page), so I get no fallback banner gallery output on the pages.

    echo '<div id="banner">';
    	if( have_rows('banner_gallery')){
    	while( have_rows('banner_gallery') ): the_row();
    		$image = wp_get_attachment_image_src(get_sub_field('banner_image'), 'bannerwide-image');
    			echo '<img src="'.$image[0].'"  />';
    	endwhile;
    	} else {  // show the gallery images assigned to home page (ID 2)
    	while( have_rows('banner_gallery',2)): the_row();
    		$image = wp_get_attachment_image_src(get_sub_field('banner_image'), 'bannerwide-image');
    			echo '<img src="'.$image[0].'" />';
    	endwhile;
    	}
    echo '</div>';
  • I logged on this morning and there was no error message about connecting to the server and I was able to save the licence key. I also updated ACF Pro to Version 5.0.7.

    I tried to save an image to the gallery without any success. I then switched theme to WordPress 2012 and could save an image to the gallery. Switched back to my own bare-bones theme and I could now also save images to the gallery so all appears to now be functioning correctly.

    I’d like to persist with ACF 5 but I’m worried about flaky performance. My theme is really stripped back and I can’t see anything in my functions.php which would affect the admin area in any way.

Viewing 7 posts - 1 through 7 (of 7 total)