Add a Custom Permalink option in the Permalink Admin Screen?

To hook your custom plugin settings into the Permalink settings, use the following: add_action(‘admin_init’, ‘wpse_237141_custom_permalink_section’); function wpse_237141_custom_permalink_section() { add_settings_section( ‘your_custom_id’, // ID ‘Your Plugin Settings’, // Section title ‘your_callback’, // Callback for your function ‘permalink’ // Location (Settings > Permalinks) ); } You’ll need to fill in the blanks to display your own custom functions, … Read more

What is the use of get_option method

Well, as you can see in the contributed example to the WordPress Reference, it is not that add_settings_field magically knows about a setting being true or false, and it is not limited to checkboxes (boolean flags): Instead, the function signature states clearly that the $callback parameter it is required. And the introduction says: The $callback … Read more

Get page slug in Admin menu

A fast and easy solution is to fetch the slug with $_GET[‘page’]. Don’t forget to do some safety checks on the query after getting it. Also, while i’m on it, to make the submenu items show up below your top level you need to change the first property of add_submenu_page to your top level slug. … Read more

Performance of several get_option() calls

If you check the implementation of get_option() you’ll see that in line 168 it calls wp_cache_get() like so: $value = wp_cache_get( $option, ‘options’ ); This means multiple calls to get_option(“style_settings”) within the same PHP execution will be served from cache. There is no need to re-invent this, as you might break other functionality with it. … Read more

How can one utilize a variable as a callback function name for add_settings_field

Do not use different callbacks, use the the sixth parameter for add_settings_field() instead. That is an array, and you can pass any data to the callback here. Example: foreach( $theOptions as $k => $v ) { add_settings_field( $k, $v, ‘my_callback’, $the_options, $the_group, array ( ‘special’ => $k ) ); } function my_callback( $args ) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)