wordpress, adding a settings action link under my plugin's name for my plugin - wordpress

I'm trying to develop my first plugin for wordpress. I noticed that other plugins I have installed on my wordpress have a link to the plugin setting page right from the plguin page list of plugins.
so right under my plugin's name I see:
Deactivate
but for some of my other plugins I also see a
Settings
link that will take the user right to the settings page of that plugin.
How can I tell wordpress I want such a link for my plugin?
I use this hook to add my settings page:
add_action('admin_menu', 'my_plugin_admin_add_page');
thanks

Please add the following code to the plugin file.
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'my_plugin_settings' );
function my_plugin_settings( $settings ) {
$settings[] = 'Settings';
return $settings;
}

Related

'use fusion builder' is not appearing in wordpress Avada theme

I have installed the AVADA theme's plugin Fusion Builder. System status is all ok.
but when I'm going to add a new page. It is not showing the 'use fusion builder' option.
I am done with updating the wordpress and all other plugins.
I have also tried making Fusion builder auto activation on. Still its not working.
Make sure Fusion Builder is enabled in Fusion Builder > Settings. Under Post Types, check the box next to the post types (post, page, etc.) with which you want to use Fusion Builder.
It seems that the Gutenberge Block editor may be the resons for your problem. The following code will de-register the block editor to re-solve the issue.
Please add the script to the functions.php : after_setup_theme action hook
add_action( 'after_setup_theme', 'tristup_setup' );
function tristup_setup()
{
add_filter('use_block_editor_for_post', '__return_false', 10);
// disable for post types
add_filter('use_block_editor_for_post_type', '__return_false', 10);
}
hope this will solve your problem.

After editing my wordpress website's footer copyright credites using My Custom Functions plugin, my site is down

I am making a wordpress store using storefront theme named Pakoutfit.com.
I tried to edit its footer credentials using My Custom Functions plugin and using this plugin I run following code,
add-action( 'init' , 'custom_remove_footer_credit' , 10 );
function custom_remove_footer_credit(){
remove_action( 'storefront_footer' , 'storefront_credit' , 20 );
add_action( 'storefront_footer' , 'custom_storefront_credit' , 20 );
}
function custom_storefront_credit(){
?>
<div class="site-info">
© PakOutfit <?php echo get_the_date( 'Y' ); ?>
</div>
<?php
}
I do that following this youtube tutorial,
Now when I tried to open my site or even its wp-admin panel it says,
This page isn’t working
pakoutfit.com is currently unable to handle this request.
HTTP ERROR 500
I dont know that in which file My custom Functions plugin make changes so that I can reverse them.
I am using godaddy domain name and hosting.
I am new in this field. Please help me to make my site live again. Thanks
Modification to your site should be made via a WordPress child theme. Do not edit core theme files: https://codex.wordpress.org/Child_Themes
Using your FTP or cPanel login, locate the file where you made the changes and remove them. That will restore your site.
Once you have your child theme installed and activated, and your function to the child theme functions.php file.
Be sure to change this:
add-action
To this:
add_action

WP Bakery Page Builder loses settings in Role Manager

We are using WP Bakery Page Builder on for a client website. The plugin works fine, but sometimes the settings in Role Manager, for what post types the composer should be on just resets.
We are researching the possibility to hack the settings programmatically to set it to On be default.
Just wanted to check if anyone else have noticed this issue.
This is a bug in older versions. The developers posted a fix for it here:
https://codecanyon.net/item/visual-composer-page-builder-for-wordpress/242431/comments?utf8=%E2%9C%93&term=add_custom_post_type_here&from_buyers_and_authors_only=0
<?php
/*
You can set the post type for which the editor should be
available by adding the following code to functions.php:
*/
add_action( 'vc_before_init', 'Use_wpBakery' );
function Use_wpBakery() {
$vc_list = array('page','capabilities','add_custom_post_type_here');
vc_set_default_editor_post_types($vc_list);
vc_editor_set_post_types($vc_list);
}
Edit: Updated link to dev comment.
Just found this on another thread, which recommended adding this to your theme's custom code:
<script>$vc_list = array( ‘page’, ‘post’ ); vc_editor_set_post_types( $vc_list );
</script>

Apply CSS file from activated WordPress Plugin

I am new to wordpress and want to know best way to add css from installed and activated plugin.
I have one activated plugin called "social-media" and in that plugin i have created one css file called "social-login-style.css"
I want to include this css file and apply style to my content. How should I add css file in any page so that I can see the effects.
In Short, I want to add social-login-style.css on wp-login.php file.
Whether it is theme or plugin, css or js, any custom addition, wp_enqueue_scripts is the only acton you need for all.
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
function additional_custom_styles() {
/* Enqueue The Styles */
wp_enqueue_style( 'custom-login-style', plugins_url( 'social-login-style.css', __FILE__ ) );
}
add_action( 'wp_enqueue_scripts', 'additional_custom_styles' );
If you it to be added only on login screen then use the following condition,
if ( $GLOBALS['pagenow'] === 'wp-login.php' ) {
// We're on the login page!
}
Hope this one help :)
UPDATE
Please check login_enqueue_scripts. it is designed to add custom scripts into login page only. Works well without any login condition.
https://codex.wordpress.org/Plugin_API/Action_Reference/login_enqueue_scripts
Without saying what you want to achieve is impossible, it certainly is against how WordPress is designed to work. Plugins are supposed to be modules that add to or modify how WordPress works. The folder of a plugin should only hold files pertaining to what the plugin does and, if it's a public plugin, its contents are controlled by a versioning (SVN) system.
In short, adding a file to an existing plugin will not have any effect, regardless of whether the plugin is active or not. And you should not add files to plugins you haven't developed yourself.
To load a CSS file on the login page, one should add an action hook to login_enqueue_scripts, as instructed in Customizing Login Form page of the codex. The stylesheet itself should be placed in either a custom plugin (you could create for your use-case) or inside the current theme folder.

I can't login on admin page after i update wordpress

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";
}
?>

Resources