Skip to content

Instantly share code, notes, and snippets.

View nash-ye's full-sized avatar
🎯
Focusing

Nashwan Doaqan nash-ye

🎯
Focusing
View GitHub Profile
@nash-ye
nash-ye / wp-disallow-authors-assigning-post-tags.php
Last active July 22, 2019 21:00
Disallow authors in WordPress from assigning post tags.
<?php
add_action('registered_taxonomy', function($taxonomy) {
global $wp_taxonomies;
if ('post_tag' === $taxonomy) {
$wp_taxonomies[$taxonomy]->cap->assign_terms = 'edit_others_posts';
}
});
@nash-ye
nash-ye / wp-include-cpt-in-dashboard-activity-widget.php
Created July 23, 2019 19:40
Include Custom Post Types In WordPress "Activity" Dashboard Widget
<?php
add_filter('dashboard_recent_posts_query_args', function(array $queryArgs) {
$postTypes = get_post_types([
'public' => true,
'capability_type' => 'post',
]);
if (is_array($postTypes)) {
$queryArgs['post_type'] = $postTypes;
@nash-ye
nash-ye / gitattributes-export-ignore-sample.txt
Last active May 22, 2020 16:54
gitattributes Sample for PHP apps
/dist export-ignore
/test export-ignore
/docs export-ignore
.gitignore export-ignore
.gitattributes export-ignore
@nash-ye
nash-ye / command-loop-wp-cli-search-replace.bash.sh
Last active July 18, 2023 12:12
A Linux command to loop through CSV file records and do WP search-replace.
while IFS=, read orig new; do wp --skip-themes --skip-plugins search-replace "$orig" "$new" wp_posts --include-columns=post_content --verbose; done < example.csv
@nash-ye
nash-ye / wp-fix-attachment-capabilities.php
Created November 3, 2020 11:00
Fixing WordPress Attachment Capabilities
<?php
add_filter(
'register_post_type_args',
function ($args, $postType) {
if ('attachment' === $postType) {
$args['capabilities']['edit_posts']   = 'upload_files';
$args['capabilities']['upload_files'] = 'upload_files';
}