Articles of plugin development

Add post type pages with plugin

Can I add the archive and single page for a custom post type added by my plugin? I know it will only have to be a best guess with contents like: <?php get_header(); ?> <h2><?php _e(‘My Post Type’, ‘my-slug’); ?></h2> <?php //get posts and list ?> <?php get_footer(); ?> Which would mean it would need […]

How to overwrite iris color pallates from theme to plugin

I am working n plugin for iris color pick and in plugin I want to make my own color pallets and overwritten on iris color picker that use in theme. I create 6 fields in plugin where user can put their color hex codes and when user save them, then they overwritten automatically on pallets […]

Include a php file from another plugin

Inside one of small custom plugins I really need to inlcude a file from another plugin, in order to be able to create and save obhect of a class that is declared there. What I have tried and the closest is this: include_once($plugin_url.’plugin-name/classes/event.php’); The error I get in the debug logs is the following: PHP […]

Is there a better way of handling AJAX requests in WordPress?

I’m currently building a pretty straightforward plugin, but it relies quite extensively on AJAX requests. I’m using the standard admin-ajax endpoint for the requests, but I find that it seems to be massively inconsistent, sometimes the request (for the same data) will take a few hundred milliseconds and then sometimes take a couple of seconds. […]

is it possible to hook every page style?

I’m trying to change the stylesheet for specific page/post while viewing in frontend, but I can’t find the hook or filter for doing that .. I’ve tried many hooks and pages and it doesn’t work Should I use page_css_class ? apply_filters( ‘page_css_class’, array $css_class, WP_Post $page, int $depth, array $args, int $current_page )

Get images / media attached to a page by page ID

I have a series of pages which have images included on them by means of the HTML editor in the admin area. I need to access these while NOT on the the actual page in question, i.e, I need to access these images by the page ID. I’ve tried using the following: $all the images […]

how to Include json manifest file in wp plugin

I want to include a json manifest file in wordpress plugin but don’t know how, this is the file that i want to include in my plugin with rel=manifest and href=manifest.json <link rel=”manifest” href=”/manifest.json”> How to do this in plugin ?

move some files of plugin to the website root directory with plugin activation

I want to move some files of the plugin to the root directory of the website after plugin activation. How can I do this?

Using ob_start() in plugin

I’m learning how to build a WordPress plugin. In the sample plugin code, I have this PHP/HTML: ob_start(); // other plugin code <?php function plugin_rvce_options_page() { ?> <div> <form action=”options.php” method=”post”> <?php settings_fields(‘plugin_options’); ?> <?php do_settings_sections(‘plugin’); ?> <input name=”Submit” type=”submit” value=”<?php esc_attr_e(‘Save Changes’); ?>” /> </form> </div> <?php } ?> Initially, this was causing the […]

How to Create Custom HTML Tag on Editor in `Text(HTML)` mode

Can you please let me know how I can add a custom Tag button into WP Editor in Text(HTML) mode like what I would like to insert into the Post is something like <hr class=”dark-line-2″ /> every time that user pushed on hr button