This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: Paulund WP List Table Example | |
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area | |
* Plugin URI: http://www.paulund.co.uk | |
* Author: Paul Underwood | |
* Author URI: http://www.paulund.co.uk | |
* Version: 1.0 | |
* License: GPL2 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Font Awesome v. 4.6. | |
function jt_get_font_icons() { | |
return array( | |
'fa-glass' => 'f000', | |
'fa-music' => 'f001', | |
'fa-search' => 'f002', | |
'fa-envelope-o' => 'f003', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tl_save_error() { | |
update_option( 'plugin_error', ob_get_contents() ); | |
} | |
add_action( 'activated_plugin', 'tl_save_error' ); | |
/* Then to display the error message: */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get the attachment absolute path from its url | |
* | |
* @param string $url the attachment url to get its absolute path | |
* | |
* @return bool|string It returns the absolute path of an attachment | |
*/ | |
function attachment_url_to_path( $url ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param string $new_status the new status of the post eg. publish | |
* @param string $old_status the old status of the post eg. draft, publish etc | |
* @param WP_Post $post | |
*/ | |
function prefix_do_something_when_a_new_post_published($new_status, $old_status, $post) { | |
// Do something On first publish | |
if ($new_status == 'publish' && $old_status != 'publish' && isset($post->post_type)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('elementor/loaded', 'prefix_register_custom_default_fonts'); | |
// register custom fonts only when elementor is ready | |
function prefix_register_custom_default_fonts(){ | |
$new_default_fonts = [ | |
//Primary Headline | |
[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A workaround for upload validation which relies on a PHP extension (fileinfo) with inconsistent reporting behaviour. | |
* ref: https://core.trac.wordpress.org/ticket/39550 | |
* ref: https://core.trac.wordpress.org/ticket/40175 | |
*/ | |
function prefix_filter_fix_wp_check_filetype_and_ext( $data, $file, $filename, $mimes ) { | |
if ( ! empty( $data['ext'] ) && ! empty( $data['type'] ) ) { | |
return $data; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
final class Sample_Plugin { | |
private static $instance; | |
// prevent direct instantiation | |
private function __construct() { | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* It removes unnecessary actions and filters to clean up the WP head to speed up | |
*/ | |
function prefix_clean_wp_head() { | |
// https://scotch.io/tutorials/removing-wordpress-header-junk | |
remove_action( 'wp_head', 'rsd_link' ); | |
remove_action( 'wp_head', 'wp_generator' ); | |
remove_action( 'wp_head', 'feed_links', 2 ); |
OlderNewer