### Callback: onSlideBefore Example Source: https://github.com/wp-plugins/wpdiscuz/blob/master/bxslider/readme.md This callback executes just before a slide transition occurs. It provides the destination slide element, the previous slide index, and the new slide index. ```javascript options: function($slideElement, oldIndex, newIndex){ // your code here } ``` -------------------------------- ### Callback: onSliderLoad Example Source: https://github.com/wp-plugins/wpdiscuz/blob/master/bxslider/readme.md This callback executes once the slider has finished loading. It receives the index of the current slide as an argument. ```javascript options: function(currentIndex){ // your code here } ``` -------------------------------- ### Utility Functions with WC_Helper Source: https://context7.com/wp-plugins/wpdiscuz/llms.txt Utilize shared utility methods for date differences, checking comment status, resolving comment ancestors, making text clickable, getting client IP, sorting comments, and retrieving user avatars. ```php global $wc_core; $helper = $wc_core->wc_helper; // --- Human-readable relative date (e.g. "2 hours 15 minutes ago") --- $relative = $helper->dateDiff(time(), strtotime($comment->comment_date_gmt), 2); // --- Check if a comment was posted today --- $today = WC_Helper::is_posted_today($comment); // bool // --- Check if comment is still within editable window --- $editable = $helper->is_comment_editable($comment); // bool // --- Resolve root ancestor of a comment (recursively) --- $root = WC_Helper::get_comment_root_id($comment_id); // --- Convert plain text URLs/emails/images to HTML links --- $html = $helper->make_clickable('Visit https://example.com or email me@example.com'); // --- Get real client IP (proxy-aware) --- $ip = WC_Helper::get_real_ip_addr(); // --- Sort parent comments ascending by ID --- $sorted = $helper->wc_sort_parent_comments($wc_parent_comments); // array of WP_Comment // --- Get user avatar (with social login plugin support) --- $avatar_html = $helper->get_comment_author_avatar($comment); // returns get_avatar() HTML (48px) ``` -------------------------------- ### Handle Subscription Confirmation and Unsubscribe URLs Source: https://context7.com/wp-plugins/wpdiscuz/llms.txt This code snippet from form.php processes GET parameters to confirm subscriptions or unsubscribe users. It requires the wc_core object to be available. ```php if (isset($_GET['wpdiscuzSubscribeID']) && isset($_GET['key'])) { $wc_core->wc_unsubscribe($_GET['wpdiscuzSubscribeID'], $_GET['key']); // Shows: "You've successfully unsubscribed." } if (isset($_GET['wpdiscuzConfirmID']) && isset($_GET['wpdiscuzConfirmKey'])) { $wc_core->wc_db_helper->wc_notification_confirm( $_GET['wpdiscuzConfirmID'], $_GET['wpdiscuzConfirmKey'] ); // Shows: "You've successfully confirmed your subscription." } ``` -------------------------------- ### Start Auto Play Source: https://github.com/wp-plugins/wpdiscuz/blob/master/bxslider/readme.md Initiates the automatic sliding of the carousel. An optional argument `false` can be passed to prevent auto controls from updating. ```javascript slider = $(".bxslider").bxSlider(); slider.startAuto(); ``` -------------------------------- ### Render Comment HTML with WC_Comment_Template_Builder Source: https://context7.com/wp-plugins/wpdiscuz/llms.txt Use get_comment_template() to build the complete HTML for a single comment. This includes avatar, author info, content, voting, reply form, and sharing options. It also provides methods to get author names and unique DOM identifiers. ```php global $wc_core; $builder = $wc_core->comment_tpl_builder; // Render a single comment $comment = get_comment(157); $depth = 1; $html = $builder->get_comment_template($comment, null, $depth); // $html is a complete
block with: // - Avatar + author role label (Guest/Member/Author/Admin) // - Author name (linked to profile if BuddyPress/UserPro/UM/UsersUltra is active) // - Relative or absolute post date // - Sanitized, linkified comment content // - Vote count + up/down thumbs (if voting enabled) // - Reply link + inline reply form (if replies allowed) // - Share buttons for Facebook/Twitter/Google+/VK/Odnoklassniki (if sharing enabled) // - Edit/Save/Cancel inline edit controls (if within editable time window) // - Toggle show/hide replies button (if comment has children) // Get author display name (handles UM, logged-in WP users, guests) $name = $builder->get_author_name($comment); // Logged-in WP user: display_name or user_login // Ultimate Member: um_user('display_name') // Guest: comment_author or "Anonymous" // Get unique DOM identifier for a comment's elements $uid = $builder->get_unique_id($comment); // Returns "{post_id}_{comment_id}", e.g. "42_157" // Used as suffix for IDs like wc-comm-42_157, vote-count-42_157, etc. // WordPress callback integration (used by wp_list_comments) add_filter('comments_template', function($file) { // wc.php hooks this to replace the default template with comment-form/form.php return plugin_dir_path(__FILE__) . 'comment-form/form.php'; }); ``` -------------------------------- ### Get Total Slide Count Source: https://github.com/wp-plugins/wpdiscuz/blob/master/bxslider/readme.md Returns the total number of slides present in the slider instance. This can be used for pagination or progress indicators. ```javascript slider = $(".bxslider").bxSlider(); var slideQty = slider.getSlideCount(); ``` -------------------------------- ### Get Current Slide Index Source: https://github.com/wp-plugins/wpdiscuz/blob/master/bxslider/readme.md Retrieves the index of the currently active slide. This is useful for tracking the slider's state. ```javascript slider = $(".bxslider").bxSlider(); var current = slider.getCurrentSlide(); ``` -------------------------------- ### Get and Save Editable Comment Source: https://context7.com/wp-plugins/wpdiscuz/llms.txt Allows logged-in users to fetch and edit their own comments within a configurable time limit. Saving validates ownership and time, then updates the comment. ```APIDOC ## AJAX: Get and Save Editable Comment ### Description Allows logged-in users to edit their own comments within a configurable time window (`wc_comment_editable_time`, default 900 seconds). Fetching retrieves raw comment content; saving validates ownership and time window, then updates the comment. ### Method POST ### Endpoint `wc_ajax_obj.url` ### Operations #### 1. Fetch Editable Comment Content ##### Parameters - **action** (string) - Required - `wc_get_editable_comment_content` - **comment_id** (integer) - Required - The ID of the comment to fetch. ##### Response - **code** (integer) - 1 for success. - **message** (string) - Raw comment text for editing. - **phrase_message** (string) - Error message if editing is not possible. #### 2. Save Edited Comment ##### Parameters - **action** (string) - Required - `wc_save_edited_comment` - **comment_id** (integer) - Required - The ID of the comment to save. - **comment_content** (string) - Required - The updated comment text. ##### Response - **code** (integer) - 1 for success, -2 if no changes, other negative for errors. - **message** (string) - The rendered (clickable links, allowed HTML) new content if successful. - **phrase_message** (string) - Error message if saving fails. ### Request Example ```javascript // Step 1: Fetch existing comment content for editing jQuery.post(wc_ajax_obj.url, { action: 'wc_get_editable_comment_content', comment_id: 157 }, function(response) { var res = JSON.parse(response); if (res.code === 1) { jQuery('#edit-textarea').val(res.message); } else { alert(res.phrase_message); } }); // Step 2: Save the edited comment jQuery.post(wc_ajax_obj.url, { action: 'wc_save_edited_comment', comment_id: 157, comment_content: 'Updated comment text with formatting.' }, function(response) { var res = JSON.parse(response); if (res.code === 1) { jQuery('#comment-157 .wc-comment-text').html(res.message); } else if (res.code === -2) { alert(res.phrase_message); } else { alert(res.phrase_message); } }); ``` ``` -------------------------------- ### Plugin Activation - Create DB Tables Source: https://context7.com/wp-plugins/wpdiscuz/llms.txt This code snippet shows how to manually trigger the creation of database tables for wpDiscuz. It's typically handled automatically on plugin activation. ```php // Plugin activation — creates DB tables // Triggered automatically on activation via register_activation_hook // Manual call if needed: $wc_core->db_operations(); // Creates: {prefix}wc_users_voted, {prefix}wc_phrases, {prefix}wc_comments_subscription ``` -------------------------------- ### Initialize bxSlider with Default Settings Source: https://github.com/wp-plugins/wpdiscuz/blob/master/bxslider/readme.md Initializes the bxSlider with default configuration. Ensure your HTML includes a container with the class 'bxslider'. ```javascript slider = $(".bxslider").bxSlider(); ``` -------------------------------- ### Public Methods Source: https://github.com/wp-plugins/wpdiscuz/blob/master/bxslider/readme.md Public methods allow programmatic control over the bxSlider instance. ```APIDOC ## Public Methods ### goToSlide Performs a slide transition to the supplied slide index (zero-based). - **Example**: ```javascript slider = $(".bxslider").bxSlider(); slider.goToSlide(3); ``` ### goToNextSlide Performs a "Next" slide transition. - **Example**: ```javascript slider = $(".bxslider").bxSlider(); slider.goToNextSlide(); ``` ### goToPrevSlide Performs a "Prev" slide transition. - **Example**: ```javascript slider = $(".bxslider").bxSlider(); slider.goToPrevSlide(); ``` ### startAuto Starts the auto show. Provide an argument `false` to prevent the auto controls from being updated. - **Example**: ```javascript slider = $(".bxslider").bxSlider(); slider.startAuto(); ``` ### stopAuto Stops the auto show. Provide an argument `false` to prevent the auto controls from being updated. - **Example**: ```javascript slider = $(".bxslider").bxSlider(); slider.stopAuto(); ``` ### getCurrentSlide Returns the current active slide. - **Example**: ```javascript slider = $(".bxslider").bxSlider(); var current = slider.getCurrentSlide(); ``` ### getSlideCount Returns the total number of slides in the slider. - **Example**: ```javascript slider = $(".bxslider").bxSlider(); var slideQty = slider.getSlideCount(); ``` ### reloadSlider Reload the slider. Useful when adding slides on the fly. Accepts an optional settings object. See here for an example. - **Example**: ```javascript slider = $(".bxslider").bxSlider(); slider.reloadSlider(); ``` ### destroySlider Destroy the slider. This reverts all slider elements back to their original state (before calling the slider). - **Example**: ```javascript slider = $(".bxslider").bxSlider(); slider.destroySlider(); ``` ``` -------------------------------- ### Access and Update Plugin Settings with WC_Options_Serialize Source: https://context7.com/wp-plugins/wpdiscuz/llms.txt Manage all plugin settings stored as a single serialized option. Access UI phrases (translatable strings) and programmatically update settings. Remember to call `update_options()` to persist changes. ```php global $wc_core; $opts = $wc_core->wc_options_serialized; // --- Key display/behavior settings --- $opts->wc_post_types; $opts->wc_comment_list_order; $opts->wc_comment_list_update_type; $opts->wc_comment_list_update_timer; $opts->wc_comment_editable_time; $opts->wc_comment_count; $opts->wc_comments_max_depth; // --- Feature toggles (0=shown/enabled, 1=hidden/disabled) --- $opts->wc_voting_buttons_show_hide; $opts->wc_share_buttons_show_hide; $opts->wc_captcha_show_hide; $opts->wc_avatar_show_hide; $opts->wc_user_must_be_registered; // --- Color customization --- $opts->wc_form_bg_color; $opts->wc_comment_bg_color; $opts->wc_reply_bg_color; $opts->wc_comment_text_color; $opts->wc_author_title_color; $opts->wc_vote_reply_color; $opts->wc_custom_css; // --- Programmatically update settings --- $opts->wc_comment_count = 10; $opts->wc_comment_list_order = 'asc'; $opts->update_options(); // persists to wp_options as serialized data // --- Phrase access --- echo $opts->wc_phrases['wc_submit_text']; echo $opts->wc_phrases['wc_reply_text']; echo $opts->wc_phrases['wc_vote_up']; echo $opts->wc_phrases['wc_held_for_moderate']; // Reload phrases from DB (respects wc_is_use_po_mo setting) $opts->init_phrases_on_load(); ``` -------------------------------- ### Configuration Options Source: https://github.com/wp-plugins/wpdiscuz/blob/master/bxslider/readme.md These options configure the behavior and appearance of the bxSlider carousel. ```APIDOC ## Configuration Options ### minSlides The minimum number of slides to be shown. Slides will be sized down if carousel becomes smaller than the original size. - **Default**: 1 - **Options**: integer ### maxSlides The maximum number of slides to be shown. Slides will be sized up if carousel becomes larger than the original size. - **Default**: 1 - **Options**: integer ### moveSlides The number of slides to move on transition. This value must be `>= minSlides`, and `<= maxSlides`. If zero (default), the number of fully-visible slides will be used. - **Default**: 0 - **Options**: integer ### slideWidth The width of each slide. This setting is required for all horizontal carousels! - **Default**: 0 - **Options**: integer ``` -------------------------------- ### WC_CSS Source: https://context7.com/wp-plugins/wpdiscuz/llms.txt This class handles dynamic style injection by outputting an inline `