to dirprocess: writing plugins rev 16 oct 2022
Category: web:cms:cp/wp:plugins
➤ common codes↓ plugins before themes↓ references↓
.......................................................
➢ common codes:
* include files with the usual include, require.
* defining paths:
plugin_dir_path( __FILE__ )
- returns the trailing slash in the filepath.
- will output relative to the current file you call it from,
so if your include statement is done from a subdirectory
inside your plugin file structure you'll get the subdirectory
back too.
plugin_dir_path(__DIR__)
- gives relative path
http://codex.wordpress.org/Function_Reference/plugin_dir_path
http://codex.wordpress.org/Determining_Plugin_and_Content_Directories
useful to define plugin directory at beginning:
define( 'PLUGIN_DIR', dirname(__FILE__).'/' );
.......................................................
➢ Plugins are loaded before themes.
You can confirm that here: Plugin API/Action Reference « WordPress Codex
You can get around this by having your plugin register your
custom post type(s) during the init action:
add_action( 'init', function() {
$args = [
'labels' => $labels,
'public' => true,
'supports' => apply_filters( "something/goes/here/supports/portfolio", [ 'title', 'editor', 'thumbnail' ],
];
// call register_post_type() here
} );
Then, the load order will work like this:
- Plugin loads and adds code to init action
- Theme loads and theme functions.php runs
- init action runs, and your plugin code executes here
- Then your theme can call
add_filter( 'something/goes/here/supports/portfolio', ... )
in functions.php and it will work as expected.
-- https://forums.classicpress.net/t/custom-post-types-supports-while-using-apply-filters-and-add-filter/3729
.......................................................
Disable update notifications for individual plugins:
https://wordpress.stackexchange.com/questions/20580/disable-update-notification-for-individual-plugins
Gives good code, plugin code, functions file, and a plugin
2012(?) to 2019(?)
.......................................................
➢ references:
PHPDoc Blocks
@link https://en.wikipedia.org/wiki/PHPDoc
@link https://docs.phpdoc.org/references/phpdoc/
@link https://docs.phpdoc.org/guides/docblocks.html
PHPDoc Markdown
@link https://sourceforge.net/p/phpdocu/wiki/markdown_syntax/
WordPress Shortcodes
@link https://developer.wordpress.org/plugins/shortcodes/
Useful plugins
@link https://developer.wordpress.org/plugins/shortcode-reference/
@link https://developer.wordpress.org/plugins/shortcodes-finder/
_______________________________________________________
begin 26 oct 2019
-- 0 --