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 | |
/** | |
* Load plugin text domain. | |
*/ | |
add_action( 'plugins_loaded', function () { | |
load_plugin_textdomain( 'text-domain', false, basename( dirname( __FILE__ ) . '/languages' ) ); | |
}, 10, 0 ); |
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 | |
/** | |
* Sets _wp_attachment_image_alt meta key for attachment images based on title. | |
* | |
* @return array | |
*/ | |
function set_images_alt_text_from_title() { | |
global $wpdb; |
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 | |
/** | |
* WordPress classes autoloader. | |
*/ | |
spl_autoload_register( function ( $class ) { | |
if ( file_exists( | |
$file = join( | |
DIRECTORY_SEPARATOR, | |
array( |
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 | |
/** | |
* PSR-4 Autoloader. | |
*/ | |
spl_autoload_register( function ( $class ) { | |
// validate namespace | |
if ( | |
strncmp( |
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 | |
trait Singleton { | |
/** | |
* @var static $instance | |
*/ | |
protected static $instance; | |
/** | |
* @return static |
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 | |
/** | |
* Imports an image from URL into media libarary. | |
* | |
* @param string $url The image URL | |
* @param string|null $title The title to use for image in the media library (also will be added as ALT text) | |
* @param int $post_parent_id Post parent ID if applicable | |
* | |
* @return int|\WP_Error ID of the newly created attachment or Wp_Error object on failure |
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 | |
spl_autoload_register( function ( $className ) { | |
if ( file_exists( $file = sprintf( '%1$s/%2$s.php', dirname( __FILE__ ), str_replace( "\\", '/', $className ) ) ) ) { | |
require_once( $file ); | |
} | |
} ); |
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
SELECT CONCAT( "ALTER TABLE ", table_name, " ENGINE=InnoDB;" ) | |
FROM information_schema.tables | |
WHERE engine = 'MyISAM' | |
AND table_schema = 'DBName'; |
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 | |
/** | |
* Adds extra CSS rules to the HEAD html tag after to your theme stylesheet. | |
*/ | |
function my_extra_css() { | |
wp_add_inline_style( | |
sanitize_title_with_dashes( wp_get_theme()->get( 'Name' ) ), | |
'/*** YOUR CSS HERE ***/' | |
); | |
} |
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 | |
/** | |
* Masks credit card number leaving up to 4 last available digits. | |
* | |
* @param string $n Credit card number (up to 16 characters) | |
* @param string $m Masking string | |
* @param int $v Maximum number of visible characters at the end of the credit card number (in range of 0-4) | |
* | |
* @return string | |
*/ |