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 get_file_extension($file) { | |
| $file_type_array = wp_check_filetype($file); | |
| if($file_type_array) | |
| { | |
| return $file_type_array['ext']; | |
| } | |
| return ''; |
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 | |
| /** | |
| * Sanitize upload filenames | |
| * For reference: | |
| * @See http://codex.wordpress.org/Function_Reference/wp_handle_upload | |
| * @See http://php.net/manual/en/function.rename.php | |
| */ | |
| if( !function_exists('vires_artes_sanitize_upload_filenames') ) { | |
| function vires_artes_sanitize_upload_filenames($vals) | |
| { |
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 hex2rgb($hex, $return_as_array = false) { | |
| $hex = str_replace("#", "", $hex); | |
| if(strlen($hex) == 3) { | |
| $r = hexdec(substr($hex,0,1).substr($hex,0,1)); | |
| $g = hexdec(substr($hex,1,1).substr($hex,1,1)); | |
| $b = hexdec(substr($hex,2,1).substr($hex,2,1)); | |
| } else { |
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 rgb2hex($rgb) { | |
| $hex = "#"; | |
| $hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT); | |
| $hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT); | |
| $hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT); | |
| return $hex; // returns the hex value including the number sign (#) | |
| } |
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 | |
| // Prevent direct file access | |
| if ( ! defined( 'ABSPATH' ) ) { | |
| header( 'Status: 403 Forbidden' ); | |
| header( 'HTTP/1.1 403 Forbidden' ); | |
| exit; | |
| } | |
| // Check if PHP is at the minimum required version | |
| if( version_compare( PHP_VERSION, '5.3', '>=' ) ) { |
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 | |
| /** | |
| * This changes logging to only log fatal errors. This file should go in your mu-plugins directory. | |
| */ | |
| // Set the error logging to only log fatal errors | |
| error_reporting( E_ERROR ); | |
| // Optional: change the location of your error log, it might be wise to put it outside your WP content dir. | |
| // If you don't change it, the default place for this log is debug.log in your WP_CONTENT_DIR. |
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
| function pw_add_image_sizes() { | |
| add_image_size( 'pw-thumb', 300, 100, true ); | |
| add_image_size( 'pw-large', 600, 300, true ); | |
| } | |
| add_action( 'init', 'pw_add_image_sizes' ); | |
| function pw_show_image_sizes($sizes) { | |
| $sizes['pw-thumb'] = __( 'Custom Thumb', 'pippin' ); | |
| $sizes['pw-large'] = __( 'Custom Large', 'pippin' ); | |
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 | |
| // Using Script Debug to load non-minified scripts | |
| $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| wp_enqueue_script( 'my_awesome_script', "my_inc_dir/javascript_file{$min}.js", array( 'jquery' ), '0.1.0', true ); | |
| // Using script debug to log data in a javascript file | |
| wp_localize_script( 'my_awesome_script', 'mas_obj', array( | |
| // Set to true if debug is enabled, false otherwise | |
| 'is_debug' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? true : false, |