I'm having some troubles with CPTs defined with custom rest_namespace at register_post_type. I keep getting an 404 error at the console. The error shows that the namespace is not being changed in autosave route. WP default namespace: wp/v2 Custom namespace defined: ek/v1 I dug into the core classes to find how Wordpress handle custom namespace. The WP_REST_Autosaves_Controler define the namespace using get_post_type_object at the __construct method: ... $post_type_object = get_post_type_object( $parent_post_type ); .... $this->namespace = ! empty( $post_type_object->rest_namespace ) ? …
I want to get the block ID of my widgets (e.g. #block-1, which is displayed on the frontend after saving a widget) on the widgets screen in the backend. What I try to achieve is to display the ID of the widget in the toolbar so that you can easily copy it. I currently use a custom API endpoint to receive the ID but it will trigger a request on every render (I already debounced it, but am searching for …
I'm running wordpress, auto-installed using the optimizied a2 hosting cpanel link. I use the 2014 theme. I updated to the most recent 4.6.1 core. It's not autosaving as described here: Wordpress Autosave. Instead, it looks like this: On several occasions, I've lost work. Sometimes, I get an "are you sure you want to do this" popup, and it reverts to just before the last time I clicked the "save draft" button. I've search for an answer, but the results all …
I'm trying to turn off autosave but it's still doing it. In wp-config.php I have: define( 'WP_POST_REVISIONS', 3 ); define('AUTOSAVE_INTERVAL', 86400); and in functions.php I have: add_action( 'admin_init', 'disable_autosave' ); function disable_autosave() { wp_deregister_script( 'autosave' ); } What am I missing?
I've searched through the similar questions but found nothing. I've coded a meta box for adding custom URL's which get added to buttons on single posts but when the URL is added to the meta box field on the Edit Post screen and saved, it strips the URL from this : http://example.com To this : httpexamplecom I assume because of the sanitize_html_classes function which is used with the save_post function like this : add_action( 'save_post', 'projecturl_save', 1, 2 ); function …
I've been struggling to find a solution for this and I don't know if it's the Gutenberg editor or if it's the hook publish_post. Hook: function api_method($post_id) { // If this is just a revision, don't send request if ( wp_is_post_revision( $post_id ) ) { return; } // Get Post Object $post = get_post($post_id); open_log($post); $postData = array( 'unit' => get_post_meta($post_id, 'open_unit', true), 'abstract' => get_post_meta($post_id, 'open_abstract', true), 'image' => get_the_post_thumbnail_url($post, 'full'), 'title' => get_the_title($post), 'url' => get_the_permalink($post), ); open_log($postData); …
I have built this script in order to display a CodeMirror in a plugin and through the CodeMirror integration I can inject and save CSS in the head of the website, the result is very cool but I would like to do something more standard and save the CSS code in a file. Here is the code: add_action('admin_enqueue_scripts', 'codemirror_enqueue_scripts'); function codemirror_enqueue_scripts($hook) { // use CodeMirror for CSS in style page $cm_settings['codeEditor'] = wp_enqueue_code_editor( array( 'type' => 'text/css', 'plugin' => 'wp-phone-message' …
I have custom post edit screen with custom metaboxes and wanted the last metabox to "Save this post and start creating a new one". It's easy to redirect user to new post creation page with url like post-new.php?post_type=customposttype but what url should I call with javascript before this to make the post saved? Thanks add_meta_box("addanotheritem", 'Add another', 'addanother_metabox', 'custompost', 'side', 'high'); function addanother_metabox() { ?> <script type="text/javascript"> function saveAndGo() { jQuery('button.editor-post-publish-button__button').click(); window.location='./post-new.php?post_type=custompost'; return false; } </script> <button onclick='javascript:saveAndGo();'>save & add …
Per default, the way to disable autosaving and post revisions, is to modify wp-config.php. Is there a way, to do that from within a plugin or a themes functions.php?
Is there a hook/function combination that can be added to my theme's functions.php to properly disable REVISIONS and AUTOSAVE for the entire wordpress installation? What about if just for a certain custom post type? Searching online gives various hacks from deregistering scripts to tampering with core files. What's the acceptable/correct way to do this?
I have a custom post type where I need to check for a duplicate record before the record actually gets saved into the database. The requirement is like this: Before saving a record, I need to check whether another record with the currently provided combination of post_title, county (meta field) and city (meta field) exists already. I have written the function for searching a similar record: function mbs_check_duplicate_record() { global $post, $wpdb; $company = $_REQUEST['post_title']; $post_type = $_REQUEST['post_type']; $country = …
I'm using following code to force WordPress page to save post as draft, is there any callback function for it, I want to alert a text after it complete saving post as draft. if ( wp.autosave.server ) { wp.autosave.server.triggerSave(); }
I have a custom Submenu page with my post type in which I am querying all posts and adding custom textareas and dropdowns that will repeat with each entry. The id and name for each field is the same accept the end of it is hyphenated with the post ID at the end. I want to be able to save the values entered in these fields and preferably once the data is entered instead of clicking a save button. I …
Hello wordpress community, we are facing the issue, that the save-button in wordpress is sometimes greyed-out (and stays that way). As far as we observed this, this usually happens on the auto-save. I am aware, that the usual reason for this would be errors in the code, but there are no errors logged in the fpm- or apache-logs. There is also no indication of a timeout (ie no 408 response code). The wordpress instance currently has 512 MB of RAM …
Does anyone know how to add autosave feature for advanced custom fields or add acf to the autosave event. I searched about it but I didn't find any solution. thank you
After saving a post I check the console and $is_autosave is simply not set function save_func($post_id){ $is_autosave = wp_is_post_autosave( $post_id ); file_put_contents('php://stderr', print_r("Autosave: ".$is_autosave, TRUE)); } add_action('save_post','save_func'); Output: Autosave: Technically since it's not an autosave the result should be: Output: Autosave: 0
I've been trying to find a filter or settings in WordPress to control the Autosave behavior, preferably by post type. When querying the database, I see our auto-drafts only go back one week, is there something in WordPress that controls this behavior? I'd like to be able to have auto-draft kept 90 days or more for some post types if possible? I read the following article regarding Autosave, perhaps I'm misunderstanding, but my experience is when I create a new …
I recently read this tutorial about custom fields in WordPress and wrote a simple plug-in to provide a metabox with a set of input fields. I do not use the Meta Box plug-in promoted on the web site. My implementation for the save_post hook is as follows: function save_my_data( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } if ( get_post_status( $post_id ) === 'auto-draft' ) { return; } if ( $parent_id = wp_is_post_revision( $post_id …
When using the classic editor, I am able to save drafts just fine. When using the normal editor, everything works except that I can't save drafts. I can publish just fine. But it otherwise gives me "Updating failed". How do I fix the hanging saving issue?