Forum Replies Created

Viewing 15 replies - 1 through 15 (of 32 total)
  • Get_field fatal error in combination with Breadcrumb NavXT WPML Extensions.

    • This reply was modified 2 years, 11 months ago by R3dRidl3.
    Thread Starter R3dRidl3

    (@r3dridl3)

    Yeah I can confirm the ACF not working properly anymore.

    Thread Starter R3dRidl3

    (@r3dridl3)

    See github for completely working code.

    Thread Starter R3dRidl3

    (@r3dridl3)

    I got a bit further, I looked into the problem and found out that the keys (field.data.key) needs to be different.
    So I got it this far working that it works in my situation. But when you use multiple flexible content fields I think it won’t work at the moment.

    Changed script.js:

    if(acf){
    
        window.acf.addAction( 'ready_field/type=flexible_content', function( field ) {
    		
    		var fieldKey = '';
    		
    		if(jQuery('.acf-flexible-content > input').attr('name').includes('_field_')){
    			//Clone field
    			var fieldKey = jQuery('.acf-flexible-content > input').attr('name').split('[');
    			fieldKey = fieldKey[fieldKey.length - 1];
    			fieldKey = fieldKey.substring(0, fieldKey.length - 1);
    		}
    		else{
    			//Base field
    			fieldKey = field.data.key;
    		}
    		
    		var hidden_layouts = window.acf_hide_layout_options.hidden_layouts[fieldKey];
    
    		// for each layout in the flexible field
    		field.$el.find( '.layout' ).each(function( i, element ) {
    			var $el = jQuery( element ),
    				$controls = $el.find( '.acf-fc-layout-controls' ),
    				index = $el.attr( 'data-id' ),
    				//name = 'acf[' + field.data.key + '][' + index + '][acf_hide_layout]',
    				name = jQuery('.acf-flexible-content > input').attr('name')+'[' + index + '][acf_hide_layout]',
    				in_array = -1 !== jQuery.inArray( index, hidden_layouts ),
    				is_hidden = in_array && 'acfcloneindex' !== index;
    
    			var $input = jQuery( '<input>', {
    				type: 'hidden',
    				name: name,
    				class: 'acf-hide-layout',
    				value: is_hidden ? '1' : '0',
    			});
    
    			var $action = jQuery( '<a>', {
    				'data-index': index,
    				'data-name': 'hide-layout',
    				href: '#',
    				title: window.acf_hide_layout_options.i18n.hide_layout,
    				class: 'acf-icon dashicons acf-hide-layout small light acf-js-tooltip',
    			});
    
    			$action.prepend( $input );
    			$controls.prepend( $action );
    
    			if ( is_hidden ) {
    				$el.addClass( 'acf-layout-hidden' );
    			}
    		});
    	});
    	
        jQuery( document ).on( 'click', '.acf-hide-layout', function() {
            var $el = jQuery( this ),
                $layout = $el.parents( '.layout' ),
                $input = $el.find( '.acf-hide-layout' ),
                value = $input.val(),
                newValue = value === '1' ? '0' : '1';
    
            $input.val(newValue);
            $layout.toggleClass( 'acf-layout-hidden', newValue );
        });
    }
    Thread Starter R3dRidl3

    (@r3dridl3)

    @joppuyo What do you think of the solution i came with?

    Thread Starter R3dRidl3

    (@r3dridl3)

    Wich would be possible with something like this:
    https://www.ibenic.com/extending-wordpress-media-uploader-custom-tab/

    Thread Starter R3dRidl3

    (@r3dridl3)

    If I understand properly, you would like the plugin to “remember” the previously cropped image sizes.

    Kinda yes, but it allso has to work with various ratio’s. When you have multiple blocks with different ratio.

    Unfortunately, the plugin is not currently designed in a way that allows re-using cropped images. There is an assumption that a cropped image belongs to a parent image, and that a cropped image belongs to a single post.

    Not always. We make complete websites and allso make use of pages with let’s say CTA blocks. These blocks often have the same image.

    So, for example, if I have a field with a 16:9 aspect ratio and I select “Image A” and crop it, the plugin would remember that there is a crop for that aspect ratio.

    What if you have several different ratio crops with the same image?

    If I then have another 16:9 field where I select “Image A” again, the plugin would by default offer that same crop (the same coordinates) and if I press crop, it would re-use the already cropped image?

    How would you be able to crop a different portion of the image? Just use the recrop?

    I’m just trying to figure out a way to implement such functionality in a smart way.

    That’s a must of course.

    I think showing the cropped images in the media gallery and having some way to detect if the image

    1. Is a cropped image
    2. Has the same aspect ratio

    And in that case, automatically selecting the image without showing the cropper would be a kind of workaround to accomplish the same functionality.

    That would be a nice starting point.

    Maye we can do something like an extra tab on the media select page:
    https://i.ibb.co/8bR6h6j/here.png

    Where it says “Previously cropped images” wich would filter out the correct sizes?
    This way you can detect if it is previously cropped and skip the crop function.
    This would be the best of 2 worlds I think. You still get to choose wich image manually, without the need to crop.

    You can do the following to achieve this.
    Only thing is you can’t press “Cancel” in the plugin to cancel the cropp if you already selected a cropped version. Need a workaround for this.

    add_filter('ajax_query_attachments_args', function ($args) {
    	if (empty($args['post__in'])) {
    		unset($args['meta_query']);
    	}
    	return $args;
    });
    Thread Starter R3dRidl3

    (@r3dridl3)

    Thread Starter R3dRidl3

    (@r3dridl3)

    Ok, will try, but should this not be an option in the plugin?

    Still the same on:

    ACF Content Analysis for Yoast SEO 2.7
    ACF Pro 5.9.0
    WP 5.5
    Yoast 14.9

    Working with text fields inside a repeater.

    • This reply was modified 4 years, 2 months ago by R3dRidl3.
    Thread Starter R3dRidl3

    (@r3dridl3)

    Hello,

    Image: JPG
    Classic editor active.
    When editing a page, click on upload media (above the WYSIWYG editor).
    Nothing special on the settings.

    Thread Starter R3dRidl3

    (@r3dridl3)

    It depends on what you want to add.

    Thread Starter R3dRidl3

    (@r3dridl3)

    Changed the code with an other filter wich works like this:

    function woocommerce_aantal_related( $args ) {
    	$args['posts_per_page'] = 8;
    	$args['columns'] = 4;
    	return $args;
    }
    add_filter( 'woocommerce_output_related_products_args', 'woocommerce_aantal_related' );
    
    function filter_related_products($args){	
    	global $product;
    	$args = array();	
    	$thiscats = wc_get_product_terms( $product->id, 'product_cat', array( 'fields' => 'slugs' ) );
    	$thistypes = wc_get_product_terms( $product->id, 'pa_model', array( 'fields' => 'slugs' ) );
    	
    	$ids_by_model_attribute = get_posts( array(
            'post_type' => 'product',
            'numberposts' => -1,
            'post_status' => 'publish',
            'fields' => 'ids',
    		'tax_query' => array(
    			'relation' => 'AND',
    				array(
    					'taxonomy' => 'product_cat',
    					'field'    => 'slug',
    					'terms'    => $cats,
    					'operator' => 'AND'
    				),
    			array(
    				'taxonomy' => 'pa_model',
    				'field'    => 'slug',
    				'terms'    => $thistypes,
    				'operator' => 'AND'
    			)
    		)
       ) );
    	
    	if($ids_by_model_attribute){
    		foreach($ids_by_model_attribute as $product_id){
    			$cats = wc_get_product_terms( $product_id, 'product_cat', array( 'fields' => 'slugs' ) );
    			$types = wc_get_product_terms( $product_id, 'pa_model', array( 'fields' => 'slugs' ) );
    			if($cats == $thiscats && $thistypes == $types){
    				array_push($args,$product_id);
    			}
    		}
    	}
    	
    	return $args;
    }
    add_filter('woocommerce_related_products','filter_related_products');
    • This reply was modified 4 years, 5 months ago by R3dRidl3.

    If this is fixed, we probably gonna use the plugin ??

Viewing 15 replies - 1 through 15 (of 32 total)