SP Project & Document Manager Shortcodes

Below, you’ll find a detailed guide on how to add the SP Project & Document Manager Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the SP Project & Document Manager Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the SP Project & Document Manager Plugin and the shortcodes it provides:

Plugin Icon
SP Project & Document Manager

"SP Project & Document Manager is a powerful WordPress plugin that allows the seamless organization and management of projects and documents within your client's workspace."

★★★★✩ (57) Active Installs: 2000+ Tested with: 6.2.3 PHP Version: false
Included Shortcodes:
  • [cdm-project]
  • [cdm-link]
  • [sp-client-media-manager]

SP Project & Document Manager [cdm-project] Shortcode

The ‘cdm-project’ shortcode from the sp-client-document-manager plugin allows us to display specific project files. By passing various attributes like ‘project’, ‘date’, ‘order’, ‘direction’, and ‘limit’, we can customize the file list. If no project is selected, it displays an error message.

Shortcode: [cdm-project]

Parameters

Here is a list of all possible cdm-project shortcode parameters and attributes:

  • project – Identifies the specific project to display.
  • date – Controls whether the date is displayed. Set to 1 to show.
  • order – Determines the order of displayed documents. Default is by ‘name’.
  • direction – Sets the direction of the ordering. Default is ascending.
  • limit – Limits the number of displayed documents. No limit if left blank.

Examples and Usage

Basic example – Display a specific project’s files by referencing the project ID.

[cdm-project project=1 /]

Advanced examples

Display a specific project’s files with a limit of 5 files, ordered by name in ascending order.

[cdm-project project=1 limit=5 order="name" direction="ASC" /]

Display a specific project’s files with a limit of 10 files, ordered by date in descending order, and including the date of each file.

[cdm-project project=1 limit=10 order="date" direction="DESC" date=1 /]

Display a specific project’s files but without any limit, ordered by name in ascending order.

[cdm-project project=1 order="name" direction="ASC" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [cdm-project] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('cdm-project', 'sp_cdm_display_project_shortcode_show');

Shortcode PHP function:

function sp_cdm_display_project_shortcode_show($atts)
    {
        global $wpdb, $current_user, $user_ID;
        $pid = $atts['project'];
        $date = $atts['date'];
        $order = $atts['order'];
        $direction = $atts['direction'];
        $limit = $atts['limit'];
        if ($order == "")
        {
            $order = 'name';
        }
        else
        {
            $order = $order;
        }
        if ($limit != "")
        {
            $limit = ' LIMIT ' . $limit . '';
        }
        else
        {
            $limit = '';
        }
        if ($pid == '')
        {
            $content .= '<p style="color:red">No project selected</p>';
        }
        else
        {
            $r = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where pid = '" . $pid . "' AND recycle = 0  order by " . esc_attr($order) . " " . esc_attr($direction) . " " . esc_attr($limit) . "", ARRAY_A);

            $content .= '<ul>';
            for ($i = 0;$i < count($r);$i++)
            {
                if ($date == 1)
                {
                    $inc_date = '<em style="font-size:10px"> - ' . cdm_datetime($r[$i]['date']) . '</em>';
                }
                else
                {
                    $inc_date = '';
                }
                $content .= '<li><a  href="' . admin_url('admin-ajax.php?cdm-download-file-id=' . base64_encode($r[$i]['id'] . '|' . $r[$i]['date'] . '|' . $r[$i]['file']) . '') . '" class="cdm-download-file-link" data-id="' . base64_encode($r[$i]['id'] . '|' . $r[$i]['date'] . '|' . $r[$i]['file']) . '" >' . stripslashes($r[$i]['name']) . '</a> ' . $inc_date . ' </li>';
            }
            $content .= '</ul>';
        }
        return apply_filters('cdm/shortcodes/cdm_project', $content, $atts);
    }

Code file location:

sp-client-document-manager/sp-client-document-manager/shortcode.php

SP Project & Document Manager [cdm-link] Shortcode

The sp-client-document-manager plugin shortcode, ‘cdm-link’, is used to generate a link to a specific file. The shortcode retrieves a file based on its ID, ‘file’. If the ‘date’ attribute is set, it includes the file’s date. If ‘real’ is set, it returns the actual URL of the file. If no file is selected, it displays a red error message.

Shortcode: [cdm-link]

Parameters

Here is a list of all possible cdm-link shortcode parameters and attributes:

  • file – Specifies the unique ID of the file to be linked
  • date – Determines if the date of the file is displayed (1 = yes, 0 = no)
  • real – Controls the type of link returned (1 = direct file URL, 0 = download link)

Examples and Usage

Basic example – The shortcode displays a link to a selected file. The ‘file’ attribute denotes the ID of the file you want to link to.

[cdm-link file=123 /]

Advanced examples

Link to a file with the date included. The ‘date’ attribute, when set to 1, appends the date of the file to the link.

[cdm-link file=123 date=1 /]

Link to the actual file instead of the download page. The ‘real’ attribute, when set to 1, changes the link so it points directly to the file.

[cdm-link file=123 real=1 /]

Link to a file with the date included and pointing to the actual file. This combines the ‘date’ and ‘real’ attributes.

[cdm-link file=123 date=1 real=1 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [cdm-link] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('cdm-link', 'sp_cdm_file_link_shortcode');

Shortcode PHP function:

function sp_cdm_file_link_shortcode($atts)
    {
        global $wpdb, $current_user, $user_ID;
        $fid = $atts['file'];
        $date = $atts['date'];
        $real = $atts['real'];
        if ($fid == '')
        {
            $content = '<a href="#" style="color:red">No file  selected</a>';
        }
        else
        {

            $r_rev_check = $wpdb->get_results($wpdb->prepare("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where parent= %d  order by date desc", $fid) , ARRAY_A);

            if (count($r_rev_check) > 0)
            {

                $r = $r_rev_check;
            }
            else
            {
                $r = $wpdb->get_results($wpdb->prepare("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where id = %d order by date desc", $fid) , ARRAY_A);
            }

            if ($real == 1)
            {
                return '' . SP_CDM_UPLOADS_DIR_URL . '' . $r[0]['uid'] . '/' . $r[0]['file'] . '';
            }
            else
            {
                if ($date == 1)
                {
                    $inc_date = '<em  style="font-size:10px"> - ' . cdm_datetime($r[0]['date']) . '</em>';
                }
                else
                {
                    $inc_date = '';
                }
                $content = '<a ' . cdm_download_file_link(base64_encode($r[0]['id'] . '|' . $r[0]['date'] . '|' . $r[0]['file']) , get_option('sp_cu_js_redirect')) . ' >' . stripslashes($r[0]['name']) . '</a> ' . $inc_date . ' </a>';
            }
            return $content;
        }
    }

Code file location:

sp-client-document-manager/sp-client-document-manager/shortcode.php

SP Project & Document Manager [sp-client-media-manager] Shortcode

The sp-client-document-manager shortcode enables users to upload and manage documents within WordPress. It checks user status, ensuring only logged-in users can upload files. It also handles errors for disabled users, and provides search and refresh functionalities.

Shortcode: [sp-client-media-manager]

Parameters

Here is a list of all possible sp-client-media-manager shortcode parameters and attributes:

  • uid – User ID to override the current logged-in user ID

Examples and Usage

Basic example – Displays the client document manager for the current user.

[sp-client-media-manager]

Advanced example – Displays the client document manager for a specific user, identified by their user ID. In this example, the user ID is 123.

[sp-client-media-manager uid=123]

Using the shortcode to display the client document manager for a specific user, and overriding the user ID if the user is logged in. If the user is not logged in, it will display a login form. The user ID is set to 123 in this example.

[sp-client-media-manager uid=123]

PHP Function Code

In case you have difficulties debugging what causing issues with [sp-client-media-manager] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('sp-client-media-manager', 'display_sp_client_upload');

Shortcode PHP function:

function display_sp_client_upload($atts)
        {
            global $wpdb;
            global $user_ID;
            global $current_user;

            $atts = shortcode_atts(array(
                'uid' => ''

            ) , $atts, 'sp-client-document-manager');

            if (@$atts['uid'] != '')
            {
                $overide_uid = $atts['uid'];
            }
            else
            {
                $overide_uid = false;
            }
            $html = '';
            wp_get_current_user();
            if (is_user_logged_in())
            {

                $disabled_users = array();
                $disabled_users_string = get_option('sp_cu_disabled_users');
                if ($disabled_users_string != '')
                {
                    $disabled_users = explode(",", $disabled_users_string);
                }
                if (in_array($current_user->ID, $disabled_users))
                {
                    $html .= '<div style="padding:10px">';
                    $html .= stripslashes(get_option('sp_cu_disabled_users_error'));
                    $html .= '</div>';
                }
                else
                {
                    $r = $wpdb->get_results($wpdb->prepare("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where uid = %d  order by date desc", $user_ID) , ARRAY_A);
                    check_folder_sp_client_upload_by_id($user_ID);
                    //show uploaded documents
                    $html .= '





 

';
                    if (get_option('sp_cu_user_disable_search') == 1)
                    {
                        $hide_search = ';display:none;';
                    }
                    $html = apply_filters('sp_cdm_above_nav_buttons', $html);
                    $html .= '<div class="cdm_nav_buttons"  id="cdm_nav_buttons">';
                    if (cdm_user_can_add($current_user->ID) == true)
                    {
                        if (class_exists('cdmPremiumUploader') && get_option('sp_cu_free_uploader') != 1)
                        {
                            global $premium_add_file_link;
                            $link = $premium_add_file_link;
                        }
                        else
                        {
                            $link = '#';
                        }
                        $html .= '  <a href="' . $link . '"  class="sp_cdm_open_modal sp_cdm_add_file hide_add_file_permission" data-modal="upload"><i class="fa fa-plus-circle" aria-hidden="true"></i> ' . __("Add File", "sp-client-document-manager") . '</a> ';
                        $addbuttons = '';
                        $addbuttons = apply_filters('sp_cdm_add_buttons', $addbuttons);
                        $html .= $addbuttons;
                        if ((get_option('sp_cu_user_projects') == 1 or current_user_can('manage_options')) && sp_cdm_is_featured_disabled('base', 'disable_folders') == false)
                        {
                            $html .= '  <a href="#" data-modal="folder" class="sp_cdm_open_modal hide_add_folder_permission"><i class="fa fa-folder" aria-hidden="true"></i> 
                            ' . sprintf(__("Add %s", "sp-client-document-manager") , sp_cdm_folder_name()) . '</a>  ';

                        }
                        $morebuttons = '';
                        $morebuttons .= apply_filters('sp_cdm_more_buttons', $morebuttons);
                        $html .= $morebuttons;
                        $html .= '   <a href="javascript:cdm_ajax_search()"  class="sp_cdm_refresh"><i class="fa fa-refresh" aria-hidden="true"></i> ' . __("Refresh", "sp-client-document-manager") . '</a> ';
                    }
                    if (sp_cdm_is_featured_disabled('base', 'disable_logout') == false)
                    {
                        $html .= '   <a href="' . cdm_logout_url() . '"  class="sp_cdm_logout" ><i class="fa fa-sign-out" aria-hidden="true"></i> ' . __("Logout", "sp-client-document-manager") . '</a> ';
                    }
                    $html .= '<div style="clear:both"></div>';
                    $html .= '</div>';
                    if (get_option('sp_cu_user_disable_search') == 1)
                    {
                        $hide_search = ';display:none;';
                    }
                    else
                    {
                        $hide_search = '';
                    }
                    $html .= apply_filters('sp_cdm/search_form', '<div style="text-align:right;padding:10px' . $hide_search . '"><input   type="text" name="search" id="search_files"><a href="#" class="sp-cdm-search-button ">' . __("Search", "sp-client-document-manager") . '</a></div>');
                    $html .= '<div class="sp-cdm-below-search-nav cdm_nav_buttons">';
                    $html = apply_filters('sp_cu_below_search_nav', $html);
                    $html .= '<div style="clear:both"></div></div>';
                    if (get_option('sp_cu_user_projects_thumbs') == 1 && cdm_is_premium_active() == 1)
                    {
                        $upload_view = display_sp_cdm_thumbnails($r, $overide_uid);
                    }
                    else
                    {
                        $upload_view = display_sp_thumbnails2($r, $overide_uid);
                    }
                    $html .= apply_filters('sp_cdm_upload_view', $upload_view, $overide_uid);
                    $html = apply_filters('sp_cdm_upload_bottom', $html);

                }
            }
            else
            {

                if (get_option('sp_cdm_use_default_login') == 1)
                {
                    return '<script type="text/javascript">

<!--

window.location = "' . wp_login_url($_SERVER['REQUEST_URI']) . '"

//-->

</script>';

                }
                else
                {

                    $html .= cdm_community_get_template('login/login.php');

                }
            }

            return $html;
        }

Code file location:

sp-client-document-manager/sp-client-document-manager/shortcode.php

Conclusion

Now that you’ve learned how to embed the SP Project & Document Manager Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *