How to add custom page elements to the WYSIWYG editor?

It’s possible to manually add buttons to your editor. https://codex.wordpress.org/TinyMCE_Custom_Buttons The Codex actually links to a full tutorial detailing the process, as well. http://code.tutsplus.com/tutorials/guide-to-creating-your-own-wordpress-editor-buttons–wp-30182 That will guide you through all the steps: Adding shortcodes to your site Creating a TinyMCE plugin (register, set up, create buttons, and add what they should do) Including editor styles … Read more

Injecting pre-defined text from custom page template to editor

The code below will work, read inline comments. Paste it into your theme functions.php or plugin. The only problem with this is the it will only work when the template is selected and the post is saved/updated and the editor is blank. <?php function wpse_177576_update_editor_content( $post_id ) { if ( wp_is_post_revision( $post_id ) ) return; … Read more

Is there a way to retrieve the calling template part?

After finding this answer, I went with: $template_tree = mytheme_get_template_tree(); $total = count($template_tree); //count the elements in the array end($template_tree); //set the pointer to the end of the array $immediate_parent = basename(prev($template_tree)); //get the filename of the penultimate element Then in a plugin / functions.php function mytheme_get_template_tree() { $included_files = get_included_files(); $stylesheet_dir = str_replace( ‘\\’, … Read more

Extract and display user infromation on an automatically created page

If I understand your question correctly, you should be able to grab the information you’re after from $the_user. If you use: $my_post[‘post_content’] = print_r($the_user,true); you should be able to see all the available user information in the page. Once you know exactly what you want, you can echo it out nicely with something like: $my_post[‘post_content’] … Read more

Create theme for mobile phones and tablets only?

It’s doable with a user agent string “sniffer”. Take a look at this project: http://mobiledetect.net Mind you, this approach can be troublesome as most modern browsers can ‘fake’ their user agent strings. Also, this approach doesn’t work to well with caching systems. I’ve implemented it successfully on a project I worked on, and I know … Read more

How to get DB options format without saving? [closed]

As I mentioned here those 2 ajax actions, here is how you can use the second action that extracts form values in db format Create an ajax action that will return the settings options You can add this code to {theme}/functions.php or to {theme}/inc/hooks.php function _action_ajax_fw_theme_get_settings_options() { wp_send_json_success(array( ‘options’ => fw()->theme->get_settings_options() )); } add_action( ‘wp_ajax_fw_theme_get_settings_options’, … Read more