Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor dan.stefan

    (@danstefan)

    Hi adeline8ope,

    You can’t use the_ID() to retrieve an id value, you must use get_the_ID() instead. the_ID echoes out the post id.

    Plugin Contributor dan.stefan

    (@danstefan)

    Hi Acal,

    Pods doesn’t change the cache-control header. It could be pods sessions that is causing this. Try this in your wp-config.php:

    define( 'PODS_SESSION_AUTO_START', false );

    Plugin Contributor dan.stefan

    (@danstefan)

    Hi 0rca,

    You could use a hook to save it as the pod is saved. Something like this for example, just replace podname with your custom pod type.

    add_filter( 'pods_api_pre_save_pod_item_podname', 'set_custom_date', 10, 2 );
    
    function set_custom_date( array $pieces, bool $is_new_item ): array {
    
    	// get field values: ok
    	$date = $pieces['fields']['custom_date']['value'];
    
    	if ( ! empty( $date ) ) {
    		if ( ! isset( $pieces['fields_active']['post_date'] ) ) {
    			$pieces['fields_active'][] = 'post_date';
    		}
    
    		//make sure that post_title is active
    		if ( ! isset( $pieces['fields_active']['post_date_gmt'] ) ) {
    			$pieces['fields_active'][] = 'post_date_gmt';
    		}
    
    		$pieces['object_fields']['post_date']['value']     = $date;
    		$pieces['object_fields']['post_date_gmt']['value'] = gmdate( 'Y-m-d H:i', strtotime( $date ) );
    
    	}
    
    	return $pieces;
    }
    
    Plugin Contributor dan.stefan

    (@danstefan)

    Hey fortiernor,

    You have to make sure post_title is an active field in the pod_array parameter, otherwise it is ignored. Something like this works for example.

    add_filter( 'pods_api_pre_save_pod_item_member', 'set_member_title', 10, 2 );
    
    function set_member_title( array $pod_array, bool $is_new_item ): array {
    
    	if ( ! $is_new_item ) {
    		return $pod_array;
    	}
    
    	// get field values: ok
    	$name      = $pod_array['fields']['lastname']['value'];
    	$firstname      = $pod_array['fields']['firstname']['value'];
    	$org      = $pod_array['fields']['org']['value'];
    
    	if ( ! empty( $org ) ) {
    		$title = $org;
    	} else {
    		$title = $firstname . ' ' . $name;
    	}
    
    	//make sure that post_title is active
    	if ( ! isset( $pod_array['fields_active'][ 'post_title' ] ) ) {
    		$pod_array['fields_active'][] = 'post_title';
    	}
    
    	if ( ! empty( $title )) {
    		$pod_array['object_fields']['post_title']['value'] = $title;
    	}
    
    	return $pod_array;
    }
    
    Thread Starter dan.stefan

    (@danstefan)

    Great! I’m mostly glad it was not a conflict with other plugins, I was quite stumped to see such high cpu usages at first with no aparent reason(my first possible suspect was thumbnail regeneration, but that worked as expected).

    Basically including the whole js file is no problem in my oppinion, as long as it doesn’t try to start something too big, anyways glad I could help. Maybe I get time further on and I can also help with this plugin since it’s quite awesome(great job btw).

    Thread Starter dan.stefan

    (@danstefan)

    @Aesque’s second post: No that was not the case, nor the problem. It happened on the edit.php page inside the admin. This is a bug, I removed everything other plugin from the server and it still used 100% cpu for about 4-5 minutes(it was just a development server, but my production server has a lot more images).

    Thread Starter dan.stefan

    (@danstefan)

    Actually the code for it is ran on the post listing pages too. You call the file_gallery_load action every time you call file_gallery.init(). Inside that action, you specifically call a require_once(‘main-form.php’). AFAIK the form is displayed only on the edit pages, however the ajax call is done on the admin post listings too since file-gallery.js is included on those pages.

    I was a wrong above in saying it’s included on all pages, it’s just included on post listing/editing screens, but while running on the post listing pages it overloads the server with requests(in the case of large media libraries)

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