sanitizing/escaping plugin options

sanitize_text_field( $str ) Sanitize a string from user input or from the db. Checks for invalid UTF-8, Convert single < characters to entity, strip all tags, remove line breaks, tabs and extra white space, strip octets http://codex.wordpress.org/Function_Reference/sanitize_text_field

How do I add a menu item to a Pods admin menu?

To add submenu items to a specific Pod’s menu, try this: add_submenu_page( ‘pods-manage-your_pod_name’, ‘My submenu item page title’, ‘My submenu item’, ‘manage_options’, ‘pods-manage-your_pod_name-my-submenu-item’, ‘your_callback_function’ ); Do this during the admin_menu action in WordPress, or alternatively do it during the ‘pods_admin_menu’ action.

wp login redirect loop reauth=1

Plugins don’t live in the root directory, and they don’t include wp-load.php or the admin.php files directly. Plugins live in the wp-content/plugins directory, and have a specific form of header, and they don’t need to include anything because WordPress includes them. You’re doing it the wrong way around, basically. A plugin would not include/require WordPress’s … Read more

WordPress dynamic widget by location?

try to make a simpler code: change $side_bar= “‘$city-Right'”; to $side_bar= $city . ‘-Right’; you have extra ‘ in $side_bar, the way you’ve done would give you ‘Madurai-Right’ but you need Madurai-Right, this way dynamic_sidebar($side_bar) would be like writing dynamic_sidebar(“‘Madurai-Right'”) while you only need dynamic_sidebar(“Madurai-Right”) besides, always avoid variable substitution, concatenation is always more secure.

Plugin admin page stylesheet doesn’t work

An alternative way to add admin scripts/styles only on your plugin’s page: //The add_action to add onto the WordPress menu. add_action(‘admin_menu’, ‘myplugin_custom_menu_page’); function myplugin_custom_menu_page() { $GLOBALS[‘my_plugin_page’] = add_menu_page( ‘My Plugin’, ‘My Plugin’, ‘manage_options’, ‘myplugin/myplugin-admin.php’, ”, plugins_url( ‘myplugin/images/icon.png’ ), 33 ); } add_action( ‘admin_enqueue_scripts’, ‘my_enqueue_scripts’ ); function my_enqueue_scripts($hook_suffix) { if( $GLOBALS[‘my_plugin_page’] == $hook_suffix ) { wp_enqueue_style( … Read more

Plugin Options not saving options and doesn’t work

You aren’t returning data from the sanitize function: function kns_sanitize_options( $input ) { $input[‘option1’] = sanitize_text_field( $input[‘option1’] ); $input[‘option2’] = sanitize_text_field( $input[‘option2’] ); } There is therefore nothing to save. Try: function kns_sanitize_options( $input ) { $input[‘option1’] = sanitize_text_field( $input[‘option1’] ); $input[‘option2’] = sanitize_text_field( $input[‘option2′] ); return $input; } Secondly, you’ve registered the name of … Read more