Skip to content

Instantly share code, notes, and snippets.

@nfsarmento
nfsarmento / functions.php
Created December 15, 2020 19:02
WordPress Allows contributors to see and manage only their custom post types and drafts from the manage posts screen.
/*
*
* Allows contributors to see and manage only their custom post types and drafts from the manage posts screen.
* src: https://wordpress.stackexchange.com/questions/89233/restrict-contributors-to-view-only-their-own-custom-post-types
*
*/
add_action( 'pre_get_posts', 'aet_filter_cpt_listing_by_author' );
function aet_filter_cpt_listing_by_author( $wp_query_obj ){
// Front end, do nothing
if( !is_admin() )
@KaineLabs
KaineLabs / yzc_restrict_content.php
Created September 6, 2020 23:35
Get Restrict Post Types for Visitors and Specific Roles and Show Restricted Content Notice
<?php
/**
* Get Restrict Post Types for Visitors and Specific Roles and Show Restricted Content Notice.
*/
function yzc_restrict_content( $content = null, $activity = null ) {
// Add Forbidden post types!
$forbidden_posts = array( 'activity_photo' );
// Add Forbidden roles.
@KaineLabs
KaineLabs / yz_enable_new_blog_posts_commenting.php
Last active February 28, 2022 16:32
Youzify - BuddyPress Enable commenting on new blog post
<?php
/*
* Enable commenting on new blog post.
*/
function yz_enable_new_blog_posts_commenting( $can_comment, $activity_type ) {
if ( $activity_type == 'new_blog_post' ) {
return true;
}
@KaineLabs
KaineLabs / yzc_change_posts_tab_post_type.php
Created June 27, 2020 05:53
Change Profile Posts Tab Post Type
<?php
/**
* Change Profile Posts Tab Post Type
*/
function yzc_change_posts_tab_post_type() {
// Add Post Type Here Below.
return 'recipes';
}
@nfsarmento
nfsarmento / single.php
Created May 18, 2020 10:56
Get Related Posts For Custom Post Type by Custom Taxonomy
<?php
// Show related posts.
// Fetch taxonomy terms for current product.
$productterms = get_the_terms( get_the_ID(), 'work_categories' );
if( $productterms ) {
$producttermnames[] = 0;
foreach( $productterms as $productterm ) {
$producttermnames[] = $productterm->name;
}
// Set up the query arguments.
<?php
/**
* Plugin Name: [Smush] - Bulk Delete Bak Images
* Plugin URI: https://premium.wpmudev.org/
* Description: Deletes all .bak images
* Author: Panos Lyrakis @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
*/
@KaineLabs
KaineLabs / yzc_get_ads_widget.php
Last active October 20, 2020 02:01
Custom Widget
<?php
/**
* Custom Widget.
**/
function yzc_get_ads_widget() {
if ( ! bp_is_single_activity() ) {
return;
}
@mzdebo
mzdebo / coronavirus_map_from_api.xml
Created April 6, 2020 15:15 — forked from carmoreira/coronavirus_map_from_api.xml
Export World Map with live info about covid-19 for Interactive Geo Maps WordPress plugin
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
@LeanSeverino1022
LeanSeverino1022 / readme.md
Last active April 28, 2021 12:29
[_Just enough wordpress] just enough stuff I need for now #wordpress
@KaineLabs
KaineLabs / yzc_change_activity_excerpt_length.php
Created November 19, 2019 17:21
Change Activity Excerpt Words Length
<?php
/**
* Change Activity Excerpt Words Length
*/
function yzc_change_activity_excerpt_length() {
// By default it's : 358 Character length.
return 400;
}