Last active
October 6, 2016 13:51
-
-
Save kaisermann/88edc898bd4605b0062ff5ad99ea9845 to your computer and use it in GitHub Desktop.
wp filters
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
add_filter('wp_update_attachment_metadata', 'filter__wp_update_attachment_metadata', 90, 2); | |
function filter__wp_update_attachment_metadata($data, $post_id) | |
{ | |
return $data; | |
$time = current_time( 'mysql' ); | |
$y = substr( $time, 0, 4 ); | |
$m = substr( $time, 5, 2 ); | |
$type = get_post_mime_type($post_id); | |
$type = explode('/', $type); | |
$ext = $type[ sizeof($type) - 1 ]; | |
$folder = 'wp-content/uploads/'; | |
$img_exts = ['jpg', 'jpeg', 'png', 'gif']; | |
if (in_array($ext, $img_exts)) | |
$folder .= $y.'/'.$m; | |
else if ($ext == 'zip') | |
$folder .= 'zip'; | |
else if ($ext == 'html') | |
$folder .= 'emails'; | |
else | |
$folder .= 'misc'.'/'.$y.'/'.$m; | |
if ($folder) | |
{ | |
add_filter('as3cf_setting_object-prefix', function() use (&$folder) | |
{ | |
return $folder; | |
}, 10,1); | |
} | |
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
add_filter('pre_option_home', 'localdev'); | |
add_filter('pre_option_siteurl', 'localdev'); | |
function localdev() | |
{ | |
if (strcasecmp($_SERVER['SERVER_NAME'], '192.168.0.54') == 0) { | |
return 'http://192.168.0.54:8888/041-tcurbes'; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment