Im creating custom user edit post interface and i need to completely remove gutenberg pos prepublish checks and publish. How can i do this?
You can disable the publish sidebar completly with
wp.data.dispatch('core/editor').disablePublishSidebar();
Simply enqueue this JS with a dependance to .
add_action( 'enqueue_block_editor_assets', function () {
wp_enqueue_script( 'so69031961', 'gutenberg-editor.js', [ 'wp-edit-post', 'wp-dom-ready' ] );
} );
This will have the same effect than unchecking this box :
So yes, your users might still be able to reactivate the checks, but it's better than nothing ;)
Related
I've made an Wordpress theme. But recently, after every change I make in the code, the cache in Chrome has to be deleted to see the change.
Can this be handled automatic with a plugin or a line of code to add to the funtions.php?
Yes, you can make the link to the css use a query string with a timestamp. This way you will get a unique link each load.
Assuming you are using wp_enque_style() to load the style, there is a version parameter, set this to the current time with the function time() and it will add it to the link.
function themeslug_enqueue_style() {
wp_enqueue_style( 'mystyle', 'path/to/mystyle.css', false, time() );
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
More info about wp_enqueue_scripts
Hi I'm trying to get WP Featherlight setup as the default lightbox, right now Visual Composer is using prettyPhoto. So I need to disable it, so that WP Featherlight will overwrite it.
I asked wpbakery and I got this response.
Hello, you can actually overwrite prettyphoto by adding prettyPhoto() in your functions.php and call another lightbox.
And from the plug-in author I got this:
Once prettyPhoto has been disabled, you shouldn't need to do anything
else to lightbox images on the site.
So it's pretty clear what I need to do. Disable prettyPhoto. But I don't know how to do that. Can I add a simple line to my child theme's functions.php? Or?
Any help would really be appreciated.
Thanks.
Place the following code in your theme's function file.
function remove_vc_prettyphoto(){
wp_dequeue_script( 'prettyphoto' );
wp_deregister_script( 'prettyphoto' );
wp_dequeue_style( 'prettyphoto' );
wp_deregister_style( 'prettyphoto' );
}
add_action( 'wp_enqueue_scripts', 'remove_vc_prettyphoto', 9999 );
I have tested this on my installation and it works flawlessly.
What it does is dequeues and deregisters the javascript and stylesheets that Visual Composer enqueues and registers throughout the plugin's PHP files for the various template elements and shortcodes that use the prettyPhoto lightbox.
The '9999' parameter enforces that the dequeuing/deregistering happens well after any enqueuing or registering took place earlier on in the loading of the plugin. Any number will do, but the higher the number the better.
You have to enqueue a custom javascript in your child theme where you override the following function:
function vc_prettyPhoto() {
}
in this way you disable prettyPhoto script initialization made by Visual Composer.
You can use code bellow to disable that javascript lib. Put that into your functions.php of theme
wp_dequeue_script( 'prettyphoto' );
wp_dequeue_style( 'prettyphoto' );
Also other page buider you can use is King Composer, which is faster VC
https://wordpress.org/plugins/kingcomposer/
Not sure if you solved the problem, but I have a solution (not very elegant, but it works).
I did buy ePix theme for a photographer and noticed that Masonry Media Grid from Visual Composer isn't fully responsive. So my soulution was to edit 3 files from wp-content/assets/js/dist. Those files are:
vc_grid.min.js
page_editable.min.js
js_composer_front.min.js
Just remove window.vc_prettyPhoto() or vc_prettyPhoto() from wherever they appear.
After that I installed Lightbox by dFactor, choose swipebox and used as selector prettyPhoto. Also I did force lightbox on link images. Now the lightbox is fully-responsive.
Hopefully this will help somebody :)
You can disable Pretty Photo. Use the below code in theme's function file, thats it.
function remove_scripts(){
wp_dequeue_script('prettyphoto' );
wp_deregister_script('prettyphoto' );
}
add_action( 'wp_enqueue_scripts', 'remove_scripts', 100 );
It will work.
I have tested on my own issue to deactivate some sliders from the Visual Composer and it works. An example how to deactivate the whole Flexslider, Nivoslider and Owl Carousel sliders in the Visual Composer plugin. Add this code into theme functions.php file:
add_action( 'wp_enqueue_scripts', 'deregister_vc_modules', 99 );
function deregister_vc_modules() {
wp_deregister_style( 'flexslider' );
wp_deregister_script( 'flexslider' );
wp_deregister_style( 'nivo-slider-css' );
wp_deregister_style( 'nivo-slider-theme' );
wp_deregister_script( 'nivo-slider' );
wp_deregister_style( 'owl-carousel' );
wp_deregister_script( 'owl-carousel' );
}
when i try to login ,displayed this: Fatal error: Call to undefined function add_menu_page() in /home/u613978711/public_html/wp-content/themes/mytheme/panel/mpane
before showed, on plugins, but when i remove plugins from FTP, now show this on THeme, how can i fix, and how can i update wordpress without any problem
#Maulik's Answer above is correct, Also you may try the following below:
Login from FTP and goto wp-content/themes and rename your theme with some other name. Once you are done, Open your home page, It'll force wordpress to apply the default theme. (Don't worry you can apply the theme again in Appearance > Themes). And try logging in again. It should work now.
If successful, Try applying the theme again.
Update the Wordpress Version so Function.php file is changed
so please create the hook
<?php
add_action('admin_menu', 'my_menu');
function my_menu()
{
add_menu_page('My Menu', 'My Test', 'manage_options', 'my-page-slug', 'my_function');
}
function my_function()
{
echo "Hello";
}
?>
Let's say I have made some changes on a php file from a certain plug-in. How do I prevent their lost when someone else decide to update this plug-in?
You should try to alter the plugin's behavior with a plugin of your own. But that depends on the nature of the changes you've done.
You can disable its update capabilities with the following filter:
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
function filter_plugin_updates( $value ) {
unset( $value->response['akismet/akismet.php'] );
return $value;
}
There are a couple of other methods to deal with this in the Answer from where I copied this code:
If I rename a plugin (in its main php file) do I still get update notifications?
Wordpress revision and autosave is keeping reverting my changes to a wordpress page. No matter how many changes I make always reverting to that point.
Is there some solution to stop doing that but not to disable revision to all site.
To Disable Autosave put the code below in your functions.php.
function disableAutoSave(){
wp_deregister_script('autosave');
}
add_action( 'wp_print_scripts', 'disableAutoSave' );
To Disable Post Revisions put the code below in your wp-config.php file.
define( 'WP_POST_REVISIONS', false ); // no revisions
Note: Using the above code will disable the Autosave and/or Post Revisions
throughout the site.
I believe the correct code should be as above code throws notification messages.
add_action( 'admin_init', 'disable_autosave' );
function disable_autosave() {
wp_deregister_script( 'autosave' );
}