This file contains 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 Photographer Name and URL fields to media uploader | |
* | |
* @param $form_fields array, fields to include in attachment form | |
* @param $post object, attachment record in database | |
* @return $form_fields, modified form fields | |
*/ | |
function be_attachment_field_credit( $form_fields, $post ) { | |
$form_fields['be-photographer-name'] = array( |
This file contains 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 rm_upld() { | |
return; | |
} | |
add_filter('media_upload_tabs', 'rm_upld', 1, 2); |
This file contains 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 hide_gallery_settings() | |
{ | |
echo '<style type="text/css">#gallery-settings{display:none;}</style>'; | |
} | |
This file contains 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('manage_media_columns', array ($this,'my_media_col')); | |
add_action('manage_media_custom_column', array ($this,'handle_my_media_col'), 10, 2); | |
function my_media_col($cols) | |
{ | |
$cols['my_col'] = 'Footer'; | |
return $cols; | |
} | |
This file contains 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
if ( current_user_can('contributor') && !current_user_can('upload_files') ) | |
add_action('admin_init', 'allow_contributor_uploads'); | |
function allow_contributor_uploads() { | |
$contributor = get_role('contributor'); | |
$contributor->add_cap('upload_files'); | |
} |
This file contains 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( 'generate_rewrite_rules', 'press_attachment_rewrite' ); | |
add_filter( 'template_redirect', 'press_redirect_old_attachment' ); | |
/* add new rewrite rule */ | |
function attachment_rewrite( $wp_rewrite ) { | |
$rule = array( | |
'media/(.+)' => 'index.php?attachment=' . $wp_rewrite->preg_index(1) | |
); | |
$wp_rewrite->rules = $rule + $wp_rewrite->rules; | |
} |
This file contains 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 arrayToObject($array) { | |
if(!is_array($array)) { | |
return $array; | |
} | |
$object = new stdClass(); | |
if (is_array($array) && count($array) > 0) { | |
foreach ($array as $name=>$value) { | |
$name = strtolower(trim($name)); | |
if (!empty($name)) { |
This file contains 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
要修改的是wordpress\wp-admin\includes\file.php | |
查找: | |
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); | |
在其后加上: | |
$fileTypeNameArr =explode("." , $filename); | |
$countNum=count($fileTypeNameArr)-1; | |
$fileExt = $fileTypeNameArr[$countNum]; //取得所上传文件后缀名 | |
$filename = time().'-'.rand(0,999999999).'.'.$fileExt;//将文件由原名改为时间戳 |
This file contains 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
//single selction | |
$(‘#selectList’).val(); | |
//get text of the option | |
$(‘#selectList :selected’).text(); | |
//from multi selction | |
var foo = []; | |
$(‘#multiple :selected’).each(function(i, selected){ |
This file contains 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 automatic_group_membership( $user_id ) { | |
if( !$user_id ) return false; | |
groups_accept_invite( $user_id, <# group ID #> ); | |
} | |
add_action( 'bp_core_activated_user', 'automatic_group_membership' ); |