Created
March 16, 2016 13:02
-
-
Save OscarAbadFolgueira/6c7c6be7073e967ea916 to your computer and use it in GitHub Desktop.
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
<?php | |
/* | |
* Plugin Name: OAF Restrict Partial Content Shortcode | |
* Plugin URI: https://www.oscarabadfolgueira.com/crear-shortcode-restringir-partes-del-contenido | |
* Description: This plugin creates a [restrict_pcs] that you can use to restrict some contents of your posts or pages. | |
* Version: 1.2 | |
* Author: Oscar Abad Folgueira | |
* Author URI: https://www.oscarabadfolgueira.com | |
* License: GPLv2 only | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
*/ | |
// If this file is called directly, abort. | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
function oaf_restrict_partial_content_shortcode( $atts, $content = null ) { | |
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) { | |
return $content; | |
} else { | |
return '<div style="background-color: #F5F2F2; padding: 5%;"><h4 style="color: red; text-align: center;">Upps, Este contenido sólo está disponible para usuarios registrados</h4></div>'; | |
} | |
} | |
add_shortcode ('restrict_pcs', 'oaf_restrict_partial_content_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment