Adding Additional Variables on Menus Page

Use the checked function. https://codex.wordpress.org/Function_Reference/checked The HTML you want to render should look like this: <input … value=”hide” checked=”checked” />Hide from these locations.</br> <input … value=”show” />Only show to these locations.</br> What you’re getting instead is probably somthing like this: <input … value=”hide” />Hide from these locations.</br> <input … value=”” />Only show to these locations.</br> … Read more

Plugin create pages and use templates

I got it. It kind of makes sense but doesnt really. The one template wasnt working becuase I was looking for just the slug. Since its a child of the other page I needed to add it in the is_page statement. This worked (I also just did it all in one function): function ch_register_page_template($page_template;) {////////////////<————-Works … Read more

Data inserted by wpdb insert is different than data pressnt in database.

wpdb::insert will only ensure that data is inserted safely (i.e prevents against SQL injection). It will not sanitize your data (e.g. stripping certain/all HTML), that’s down to you. You can either use wp_strip_all_tags, which removes all HTML, or a variation of wp_kses, which is a sophisticated library for removing certain (x)HTML tags & entitites. The … Read more

Adding another field to user table

It’s easy. Just add function with your options to show_user_profile and edit_user_profile hooks, and save them on personal_options_update and edit_user_profile_update. Like this for instance (you can add your own fields (text, number etc.)) /********* Additional User Content ***********/ add_action( ‘show_user_profile’, ‘mytheme_extra_profile_fields’ ); add_action( ‘edit_user_profile’, ‘mytheme_extra_profile_fields’ ); function mytheme_extra_profile_fields( $user ) { ?> <?php $customData = … Read more

Call to undefined function error in plugin

You can try following while you get such error: Searched for the php file with the function definition in it. Verified that the file exists. Verified that the require (or include) statement for the above file exists in the page. Also, verified the absolute path in the require/include is correct. Verified that the filename is … Read more

custom wp_editor does not save the content in plugin settings

Might be possible that your wp_editor is broken! According to codex you can not use numeric editor ID may only contain lowercase letters and underscores…hyphens will cause editor to not display properly Call wp_editor in this way wp_editor( $nga_textarea_field_1_invalid, ‘nga_textarea_field_one’ ); textarea_name is not required because by default it is already wp_editor ID. I am … Read more