i created a wp plugin, now, whenever i change it through
a) editor,
b) manually in Sublime Text2 and then delete from wp, and re-upload the changed version
and go to page with shortcode that's supposed to trigger plugin, i see no changes. i now have just few words and no html tags whatsoever in php page its supposed to include, it still displays the old html table that was there
here's the code i use to activate the plugin when i 'install' it in WP
register_activation_hook( __FILE__, 'act');
function act(){
add_option('Activated_Plugin','Plugin-Slug');
/* activation code here */
}
function getxml( $atts ){
include 'getxml.php';
}
add_shortcode( 'boixml', 'getxml' );
Did you install W3 Total Cache or WP Super Cache plugins?
Try that link may it give you the key to solve that problem
http://codex.wordpress.org/WordPress_Optimization/Caching
Related
The Mega Menu plugin works well except when activated it affects But some WordPress Dash icons not showing properly.
I have already installed cache plugins like Autoptimize and WP Rocket as well.
After clear cache from admin side but don't work till now. Also not giving any error in the Browser console.
URL: https://www.socomtactical.net
Max Mega Menu Plugin: https://wordpress.org/plugins/megamenu/
Note: I can't use Elemetor on my Website.
Screenshot:
Please let me know what is actually issue?
Thank you.
If you want to add Dashicons on WordPress frontend, you will need to enqueue them using PHP code in your theme functions.php file:
/* Add Dashicons in WordPress Front-end */
add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' );
function load_dashicons_front_end() {
wp_enqueue_style( 'dashicons' );
}
Sample :
<i class="dashicons dashicons-admin-comments"></i>
Chose icon
WP 5.8 comes with a new system to manage events named "Widgets Block Editor". How can I disable this new system and restore the classic widget editor of WordPress?
Method 1:
Do you want to disable the new widget block editor page of Gutenberg and bring back the old widgets page?
You can do that simply by adding this line into your theme's functions.php file:
// Disables the block editor from managing widgets in the Gutenberg plugin.
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false', 100 );
// Disables the block editor from managing widgets. renamed from wp_use_widgets_block_editor
add_filter( 'use_widgets_block_editor', '__return_false' );
Don't forget to save the functions.php file.
Method 2:
If you don't need to edit the functions.php file of your theme, install and activate any one plugin, and the old widgets page will be back:
https://wordpress.org/plugins/disable-gutenberg/
https://wordpress.org/plugins/classic-widgets/
Tested & working for me.
Hope this is helpful for you.
Thanks in advance
To disable the new WordPress widget editor system you can use one of following methods.
1. Install and Activate the Disable Widget Block Editor plugin.
2. Use use_widgets_block_editor filter to disable it. You can place following code in your theme functions.php file or your plugin.
add_filter( 'use_widgets_block_editor', '__return_false' );
3. Use following code in functions.php of your theme to declare that your theme doesn't support the new widget editor system.
remove_theme_support( 'widgets-block-editor' )
// Disables the block editor from managing widgets in the Gutenberg plugin.
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false', 100 );
// Disables the block editor from managing widgets.
add_filter( 'use_widgets_block_editor', '__return_false' );
It appears that one of the filters has been renamed. It is no longer "wp_use_widgets_block_editor", it's just "use_widgets_block_editor".
The most upvoted answer by #Savan Dholu should be edited to reflect that (I'm afraid I can't comment as I'm missing enough reputation * ROLLEYES *).
You can install the plugin (rather than codes that might break your website) which is introduced in the new Widget Editor guide: Classic Widgets
I have a function in my theme functions.php file which returns a value:
function my_theme_function() {
return "100";
}
Anywhere in my theme templates I can simply do this...
echo my_theme_function()
...and I see the number 100 on the page. That's cool.
But in my plugin I would have expected to be able do also get access to this function by echoing my_theme_function() but instead I get a 'call to undefined function' error.
The strangest part is I'm certain this was working a couple of days ago, but I've not touched the code since. I suspect some WordPress shenanigans, but I don't know why or how to get around this.
The reason you may take this result can be the order in which the theme and the plugins are loaded.
For example, your plugin can get loaded before the theme, and obviously, in this case, the function it is not available in your plugin source code.
The solution to this issue are the WordPress Hooks. I don't know what is your plugin code style, but you can bootstrap your plugin in the init hook or even better in the after_setup_theme.
So for example, let's say, you need your plugin should run once your theme is loaded by the WordPress. You can use the following code to do so:
function my_theme_is_loaded() {
// Bootstrap your plugin here
// OR
// try to run your function this way:
if ( function_exists( 'my_theme_function' ) ) {
my_theme_function();
}
}
// You can also try replace the `after_setup_theme` with the
// `init`. I guess it could work in both ways, but whilw your
// plugin rely on the theme code, the following is best option.
add_action( 'after_setup_theme', 'my_theme_is_loaded' );
What the above code does, is like you say to your plugin, wait until the theme is totally loaded, and then try to run my plugin code that rely on the theme code.
And of course, I suggest either wrap your theme function in a plugin function like that:
// This way, your plugin will continue running even if you remove
// your theme, or by mistake your rename the function in the theme
// or even if you totally decide to remove the function at all in the
// side of the theme.
function function_from_theme() {
if ( function_exists( 'my_theme_function' ) ) {
return my_theme_function();
} else {
return 0; // Or a value that is suitable with what you need in your plugin.
}
}
This is going to protect your site against theme de-activation or theme change. In this cases, you are going to have a plugin looking for a function in your theme, and while you change the theme or deactivate your theme, your plugin will break your site.
So I installed this plugin https://wordpress.org/plugins/wp-db-table-editor/
In "how to install", it says I have to call the add_db_table_editor function in my theme’s functions.php in order for the plugin interface to show
Installing screenshot
I added this code at the very bottom of functions.php file, and when I refresh my website, it won't load.
This is my code (i'm very new to coding):
function add_db_table_editor(){
if(function_exists(‘add_db_table_editor’)){ add_db_table_editor(‘title=Employees&table=employees’);
add_db_table_editor(array( ‘title’=>’Test title’, ‘table’=>’wp_posts’, ‘sql’=>’SELECT));
}
}
In wordpress you have to go to
{wpinstallfolder}/wp-content/themes/{active_theme}
inside that active_theme folder you should find the
functions.php
Before you add any code to the functions.php you need to back it up, to revert back to in case you do not edit it properly.
Open it up and add the lines that the plugin told you to add. and save it.
This is a formated code block to help you
function add_db_table_editor(){
if(function_exists('add_db_table_editor')){
add_db_table_editor('title=Employees&table=employees');
add_db_table_editor(array( 'title'=>'Test title', 'table'=>'wp_posts', 'sql'=>'SELECT * FROM event_registrations ORDER BY date_entered DESC'));
}
}
i've written a plugin which shortcodes can easily be used in every post and page. As this plugin can be useful in a sidebar as well i want to make the text widget usable for my shortcodes.
When i googled this i found out that i can use the add_filter() function to ensure that, but this is only possible if i have access to the theme's functions.php. But as i am the creator of the plugin and not of the theme, this is not usable for me.
Does anybody know how i can make a shortcode which is introduced with a plugin usable in the widgets section?
Thanks!
Open your theme's function file.
Find a free spot after the opening php tag that isn't part of a function.
add this:
if (!is_admin())
{
add_filter('widget_text', 'do_shortcode', 11);
}
save the file and you should be all set.
Open your page in edit mode.
Select your page location and line where you want to add short code.
Add code here and update..