/** * Add edd_restrict shortcode * * @since 1.0.0 * @param array $atts The attributes to pass to the shortcode * @param string $content The content of the shortcode * @return string $content The data to return for the shortcode */ function edd_cr_restrict_shortcode($atts, $content = null) { $atts = shortcode_atts(array('id' => null, 'price_id' => null, 'message' => null, 'class' => ''), $atts); if (!is_null($atts['id'])) { $ids = explode(',', $atts['id']); $restricted_to = array(); foreach ($ids as $download_id) { $restricted_to[] = array('download' => $download_id, 'price_id' => $atts['price_id']); } $content = edd_cr_filter_restricted_content($content, $restricted_to, $atts['message'], 0, $atts['class']); } return $content; }
/** * Filter content to handle restricted posts/pages * * @since 1.0.0 * @param string $content The content to filter * @global object $post The post we are editing * @return string $content The filtered content */ function edd_cr_filter_content($content) { global $post; // If $post isn't an object, we aren't handling it! if (!is_object($post)) { return $content; } $restricted = edd_cr_is_restricted($post->ID); if ($restricted) { $content = edd_cr_filter_restricted_content($content, $restricted, null, $post->ID); } return $content; }