How to use wp-post editor in plugin - wordpress

I want to use the post editor of wordpress in one of the plugins I'm developing. How am I supposed to add the editor to the plugin.

Atlast I figured out a way to add the tiny-mce editor on my plugin.
You have to add a few script(s) and the post editor of wordpress will be available for you.
This is the code to use:
wp_enqueue_script( 'common' );
wp_enqueue_script( 'jquery-color' );
wp_enqueue_script('utils');
if (function_exists('add_thickbox')) add_thickbox();
wp_print_scripts('media-upload');
if (function_exists('wp_tiny_mce')) wp_tiny_mce();
wp_admin_css();
wp_print_scripts('editor');
do_action("admin_print_styles-post-php");
do_action('admin_print_styles');
It's enough to add the tiny mce editor on your plugin.
Now the following line is necessary to display the editor:

Related

Show Featured Image in Wordpress Editor

I'm creating a website with wordpress but I cannot see featured image in both screen options or editor
This is blank Wordpress install 5.3.2, I develop new web from scratch so I don't think problem related to other plugins
Go into your themes functions.php and paste the following code inside:
add_theme_support( 'post-thumbnails' );
Reference: https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
Hope you can use it to solve your problem.

'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.

Woocommerce 3.0.3 lightbox doesn't work

I have a shop website with woocommerce 3.0.3 and on product detail page using default woocommerce templates, there is an issue with lightbox about clicking on the main image or gallery images. The site redirects me to a page with the image link instead of showing the lightbox.
You just need to add these lines in your function.php file and your lightbox (photoswipe) will work absolutely fine.
if(class_exists('WooCommerce')){
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
Hope this helps
I found the solution. In latest version woocommerce-3.0.3, lightbox is replaced with photosswipe. Photoswipe is disabled in my theme. It works only if the theme add support like add_theme_support('wc-product-gallery-lightbox') then it works like a charm
The problem is not only the missing add_theme_support('wc-product-gallery-lightbox')
If the DOM structure is not the same as the updated files: product-thumbnail.php and product-image.php - then the add_theme_support function won't help you.
Copy these files from WooCommerce plugin to your theme, and it should work.

Why my wordpress plugin is not working in my themes?

I have create an plugin, it's featured image option working in wordpress default theme(twenty thirteen/forteen ) but not working others themes.
Any Idea ?
Themes have to declare their support for post thumbnails before the
interface for assigning these images will appear on the Edit Post and
Edit Page screens. They do this by putting the following in their
functions.php file:
add_theme_support( 'post-thumbnails' );
Source: http://codex.wordpress.org/Post_Thumbnails#Enabling_Support_for_Post_Thumbnails

In Wordpress CMS, the controls under the WYSIWYG editor

I want to create a wordpress plugin where it adds additional controls underneath the WYSIWYG editor when adding pages/posts. But I don't know what keywords I'm supposed to google for to find relevant tutorials on how to do it.
Can someone provide me with resources?
It's called add_meta_box() - call it within a hooked admin_init function like so;
function my_custom_meta_box()
{
add_meta_box(
'my_meta_box_id',
'My Meta Box Title',
'my_meta_box_callback',
'post', // either post, page or link,
'normal', // position of the meta box,
'high' // position priority
);
}
add_action('admin_init', 'my_custom_meta_box');
function my_meta_box_callback()
{
echo 'This is the content of my meta box!';
}
Do you want the filter reference for hooks to add to the editor? Plugin API/Filter Reference « WordPress Codex There are lots of plugins that add controls to the editor: WordPress › WordPress Plugins - TinyMCE
I've written a good tutorial on adding WordPress Meta Boxes additionally check out my WPalchemy Meta Box PHP Class which will help you create meta boxes with ease.

Resources