/**
 * Get the display name of the owner of a post
 * 
 * @param int $post_id
 * @return mixed
 */
function cuar_get_the_owner($post_id = 0)
{
    $cuar_plugin = CUAR_Plugin::get_instance();
    $po_addon = $cuar_plugin->get_addon('post-owner');
    $post_id = $post_id == 0 ? get_the_ID() : $post_id;
    $owner_name = $po_addon->get_post_owner_displayname($post_id);
    return apply_filters('cuar/private-content/the-owner', $owner_name, $post_id);
}
/**
 * Add the full width body class to our private post types
 */
function cuar_body_class($classes)
{
    if (!class_exists('CUAR_Plugin')) {
        return $classes;
    }
    $post_type = get_post_type();
    $private_post_types = CUAR_Plugin::get_instance()->get_private_post_types();
    if (in_array($post_type, $private_post_types)) {
        $classes[] = 'full-width';
    }
    return $classes;
}
 protected function get_form_field_input($id, $value)
 {
     if ($this->enable_rich_editor && !$this->readonly) {
         ob_start();
         $editor_settings = CUAR_Plugin::get_instance()->get_default_wp_editor_settings();
         $editor_settings['textarea_name'] = $id;
         wp_editor($value, $id, $editor_settings);
         $out = ob_get_contents();
         ob_end_clean();
         return $out;
     } else {
         return sprintf('<textarea rows="5" cols="40" id="%1$s" name="%2$s" class="%4$s" %5$s>%3$s</textarea>', $id, $id, $value, 'form-control', $this->readonly ? 'readonly="readonly"' : '');
     }
 }
 /**
  * Actually process the shortcode (output stuff, ...)
  *
  * @param array  $params  The parameters
  * @param string $content The content between the shortcode tags
  *
  * @return string The shortcode final output
  */
 public function process_shortcode($params, $content)
 {
     // Do not consider guests
     if (!is_user_logged_in()) {
         return '';
     }
     $plugin = CUAR_Plugin::get_instance();
     $current_user_id = get_current_user_id();
     $layout = $params['layout'];
     $type = $params['type'];
     // Build the query
     $args = array('post_type' => $type, 'posts_per_page' => $params['max_items']);
     // Ownership / authorship
     switch ($params['show']) {
         case 'owned':
             /** @var CUAR_PostOwnerAddOn $po_addon */
             $po_addon = $plugin->get_addon('post-owner');
             $args['meta_query'] = $po_addon->get_meta_query_post_owned_by($current_user_id);
             break;
         case 'authored':
             $args['author'] = $current_user_id;
             break;
         default:
             return sprintf(__('The parameter %2$s of shortcode <code>[%1$s]</code> has an invalid value: <code>%3$s</code>', 'cuar'), $this->name, 'show', $params['mode']);
     }
     // Taxonomy
     $terms = explode(',', $params['terms']);
     if (!empty($params['taxonomy']) && !empty($terms)) {
         $args['tax_query'] = array(array('taxonomy' => $params['taxonomy'], 'field' => $params['terms_field'], 'terms' => $terms, 'operator' => $params['terms_operator']));
     }
     $query = new WP_Query(apply_filters('cuar/shortcodes/protected-content/query-args', $args, $params));
     // Determine the template files to use
     $template_root = CUAR_INCLUDES_DIR . '/core-addons/shortcodes';
     if ($query->have_posts()) {
         $loop_template = $plugin->get_template_file_path($template_root, array('protected-content-shortcode-loop-' . $layout . '-' . $type . '.template.php', 'protected-content-shortcode-loop-' . $layout . '.template.php', 'protected-content-shortcode-loop-' . $type . '.template.php', 'protected-content-shortcode-loop-default.template.php'));
     } else {
         $loop_template = $plugin->get_template_file_path($template_root, array('protected-content-shortcode-empty-' . $layout . '-' . $type . '.template.php', 'protected-content-shortcode-empty-' . $layout . '.template.php', 'protected-content-shortcode-empty-' . $type . '.template.php', 'protected-content-shortcode-empty-default.template.php'));
     }
     $before_items_template = $plugin->get_template_file_path($template_root, array('protected-content-shortcode-layout-' . $layout . '-' . $type . '-before.template.php', 'protected-content-shortcode-layout-' . $layout . '-before.template.php', 'protected-content-shortcode-layout-' . $type . '-before.template.php', 'protected-content-shortcode-layout-default-before.template.php'));
     $after_items_template = $plugin->get_template_file_path($template_root, array('protected-content-shortcode-layout-' . $layout . '-' . $type . '-after.template.php', 'protected-content-shortcode-layout-' . $layout . '-after.template.php', 'protected-content-shortcode-layout-' . $type . '-after.template.php', 'protected-content-shortcode-layout-default-after.template.php'));
     $item_template = $plugin->get_template_file_path($template_root, array('protected-content-shortcode-layout-' . $layout . '-' . $type . '-item.template.php', 'protected-content-shortcode-layout-' . $layout . '-item.template.php', 'protected-content-shortcode-layout-' . $type . '-item.template.php', 'protected-content-shortcode-layout-default-item.template.php'));
     ob_start();
     include $loop_template;
     $out = ob_get_contents();
     ob_end_clean();
     return $out;
 }
 /**
  * Print a list of posts
  *
  * @param array $posts The posts
  */
 protected function print_content_list($posts)
 {
     $template = CUAR_Plugin::get_instance()->get_template_file_path(CUAR_INCLUDES_DIR . '/core-classes', "widget-content-list-" . $this->id_base . ".template.php", 'templates', "widget-content-list.template.php");
     include $template;
 }
/**
 * Returns true if the type of the given post is a private post type of Customer Area
 *
 * @param WP_Post|int $post The post/post ID to test
 *
 * @return boolean
 */
function cuar_is_customer_area_private_content($post = null)
{
    $cuar_plugin = CUAR_Plugin::get_instance();
    $private_types = array_merge($cuar_plugin->get_content_post_types(), $cuar_plugin->get_container_post_types());
    return in_array(get_post_type($post), $private_types);
}
 protected function get_link($author_id)
 {
     $cuar_plugin = CUAR_Plugin::get_instance();
     $cfp_addon = $cuar_plugin->get_addon('customer-private-files');
     return $cfp_addon->get_author_archive_url($author_id);
 }
Exemple #8
0
</h2>

    <form method="GET" action="<?php 
echo admin_url('admin.php');
?>
">
        <input type="hidden" name="cuar-do-logs-action" value="1"/>
        <input type="hidden" name="page" value="<?php 
echo $_REQUEST['page'];
?>
"/>

        <?php 
$start_date = isset($_POST['start-date']) ? sanitize_text_field($_POST['start-date']) : '';
$end_date = isset($_POST['end-date']) ? sanitize_text_field($_POST['end-date']) : '';
$logger = CUAR_Plugin::get_instance()->get_logger();
$type_filter = isset($_POST['filter-by-type']) ? $_POST['filter-by-type'] : 0;
?>

        <?php 
$logs_table->views();
?>
        <br/>
        <div class="cuar-list-table-filter">
            <a class="cuar-filter-toggle"><?php 
_e('Toggle advanced filters', 'cuar');
?>
</a>

            <?php 
$collapse_panel = $logs_table->is_search_active() ? '' : 'display: none;';
/**
 * Get the type of the file associated to the given post
 *
 * @param int $post_id
 *
 * @return string|mixed
 */
function cuar_get_the_file_size($post_id = null, $human = true)
{
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    if (!$post_id) {
        return '';
    }
    $cuar_plugin = CUAR_Plugin::get_instance();
    $pf_addon = $cuar_plugin->get_addon('private-files');
    $size = $pf_addon->get_file_size($post_id);
    if (false === $size) {
        return '';
    }
    if ($human) {
        $size = cuar_format_human_file_size($size);
    }
    return apply_filters('cuar/private-content/files/the-size', $size, $post_id);
}
Exemple #10
0
 /**
  * Load theme particular scripts
  */
 function cuar_load_theme_scripts()
 {
     $cuar_plugin = CUAR_Plugin::get_instance();
     $cuar_plugin->enable_library('bootstrap.dropdown');
     $cuar_plugin->enable_library('bootstrap.collapse');
 }
 /**
  * Print the list of terms
  *
  * @param array   $terms The terms
  * @param boolean $hide_empty Shall we hide empty terms?
  */
 protected function print_term_list($terms, $hide_empty)
 {
     $template = CUAR_Plugin::get_instance()->get_template_file_path(CUAR_INCLUDES_DIR . '/core-classes', "widget-terms-" . $this->id_base . ".template.php", 'templates', "widget-terms.template.php");
     include $template;
 }
 protected function get_link($term)
 {
     $cuar_plugin = CUAR_Plugin::get_instance();
     $cfp_addon = $cuar_plugin->get_addon('customer-private-pages');
     return $cfp_addon->get_category_archive_url($term);
 }
 protected function get_link($year, $month = 0)
 {
     $cuar_plugin = CUAR_Plugin::get_instance();
     $cfp_addon = $cuar_plugin->get_addon('customer-private-files');
     return $cfp_addon->get_date_archive_url($year, $month);
 }
 /**
  * Handles remote requests to validate a license
  */
 public static function ajax_validate_license()
 {
     $cuar_plugin = CUAR_Plugin::get_instance();
     $addon_id = $_POST["addon_id"];
     $license = $_POST["license"];
     /** @var CUAR_AddOn $addon */
     $addon = $cuar_plugin->get_addon($addon_id);
     $license_key_option_id = $addon->get_license_key_option_name();
     $cuar_plugin->update_option($license_key_option_id, $license);
     $licensing = $cuar_plugin->get_licensing();
     $result = $licensing->validate_license($license, $addon);
     $today = new DateTime();
     $license_check_option_id = $addon->get_license_check_option_name();
     $cuar_plugin->update_option($license_check_option_id, $today->format('Y-m-d'));
     $license_status_option_id = $addon->get_license_status_option_name();
     $cuar_plugin->update_option($license_status_option_id, $result);
     echo json_encode($result);
     exit;
 }