Simple:Press Documentation

Plugin: Answers Topic

Plugin Description –

This Simple:Press plugin allows a user who starts a topic (or a forum Admin or Moderator) to indicate that a reply post within the topic by a forum member other than the topic originator answers the topic.

Plugin Overview

  • Provides a button on reply posts where the topic initiator/author, forum Admin, or Moderator can mark the reply post as answering the topic.
  • Provides a message on the selected reply post indicating it ‘Answers Post’ and in some themes displays the “answers post” icon.
  • Provides a button on the selected reply post where the topic originator/author, forum Admin, or Moderator can deselect the post possibly in favor of another reply or if marked by mistake.
  • Provides interface with the Simple:Press MyCred Integration plugin and the WordPress myCRED plugin to reward the “Answers Post” reply post author.

Plugin Features

Installing this Simple:Press plugin adds:

  • A new “Answers Topic” section in the “Available Plugins – Install Simple:Press Plugins” panel under the forum Admin menu path Forum > Plugins > Available Plugins. From this panel the plugin can be activated, or deleted by the admin.
  • When properly installed, a new folder in the “forum-plugin” folder named “answers-topic” containing the plugin’s files.

Activating this plugin provides:

  • A change to the new “Answers Topic” section in the Plugin Management panel under the Admin menu path Forum > Plugins > Available Plugins so the plugin can be deactivated, or uninstalled.
    • There are no options for this plugin.
    • The “Getting Started” link associated with the “Deactivate/Uninstall” selections should be selected to view the pertinent information regarding the plugin.
  • A new button, “Answers Topic” on each reply post (other than those of the topic originator/author) in the topic on the Topic View page where the originator/author of the topic, forum Admin, or Moderator can select the reply as “Answers Post”.
  • A new icon ( a check mark on a green circular background) and message “Answers Post” shown on the reply post in the topic that has been selected as best answering the topic.
  • A new button “Unmark as Answer” shown on the reply post in the topic selected as best answering the topic where the topic originator/author, forum Admin, or Moderator can deselect the post possibly in favor of another post that better answers the topic or if the post was marked by mistake.
  • A new button “See Answer” on the topic’s original post that provides a link to the reply post selected as best answering the topic.
  • In phpMyAdmin, a new column “answered” in ‘xx_sftopics’ table of the website’s database where the post ID of the reply post that answered the topic can be seen by the database admin, if the topic originator/author has selected a reply topic as best answering the topic. The “xx” is the table prefix assigned when the Simple:Press forum database was set up.

There are no new permissions added to the permission sets due to this plugin. However, a user must have the “Can start new topics in a forum” permission in order to use this plugin.

Plugin Requirements

Simple:Press version 5.5.7 and above is required.

As part of the installation, an “Answers Topic” section is added to the Plugin Management panel under the admin menu Forum > Plugins > Available Plugins. From this panel the plugin can be activated, deactivated, uninstalled, or deleted.

  • There are no options that need be set up for this plugin.

There are no new permissions added to the permission sets due to this plugin. However, a user must have the “Can start new topics in a forum” permission in order to use this plugin.

The plugin has three (3) template tags ‘sp_AnswersTopicPostIndexAnswer()’, ‘sp_AnswersTopicAnswer()’, and ‘sp_AnswersTopicSeeAnswer()’ incorporated into standard supplied Simple:Press themes.

  • If the location of the template tags in the themes as well as the argument and parameter values for the template tag are acceptable, nothing need be done.
  • If any item relating to the template tags is to be modified or if any other template tag is to be added to a theme, it is recommended that a Child or Custom theme is created first to accept the changes prior to installing this plugin.
  • In all cases the template tags should be called conditionally, if (function_exists(‘ ‘)) so that if the plugin is deactivated or does not exist, the website will continue to operate.

Plugin Installation and Activation

Please see Using Plugins on how to obtain and install this plugin.

  • Whatever method is used to add the Simple:Press plugin, the folder that should have been added to the forum plugin folder is named “answers-topic“.
  • If using the “Simple:Press Upload Plugin – Upload a Simple:Press Plugin” panel at the forum Admin menu Forum > Plugins > Plugin Uploader, the folder to browse for after downloading it from the Simple:Press site is “answers-topic.zip” before clicking the “Upload Now” button.

As mentioned there the default location for Simple:Press plugin folders is …/wp-content/sp-resources/forum-plugins. If this path is changed, it is important to note that the plugin’s folder and its content need to reside in the forum plugins folder wherever it has been moved and however it has been renamed. See Storage Locations for more information.

Activation is accomplished from the Admin Dashboard panel menu by selecting Forum > Plugins > Available Plugins from the drop down forum Admin menu. On the “Available Plugins – Install Simple:Press Plugins” panel select the “Answers Topic” plugin and click on “Activate”. The “Activate/Delete” label changes to “Deactivate/Uninstall” with a “Get Started” Link.

  • The “Getting Started” link associated with the “Deactivate/Uninstall” selections should be selected to view the pertinent information regarding the plugin.

To deactivate the plugin, click on “Deactivate”. The “Deactivate/Uninstall” label changes to “Activate/Delete”.
To re-activated the plugin, click on on “Activate”. The “Activate/Delete” label changes to “Deactivate/Uninstall”.

Plugin Administrative Options

After installing and activating, there are no Administrative Options to be set for this plugin.

There are no new permissions that must be set in the permission sets because of this plugin. However, a user must have the “Can start new topics in a forum” permission in order to use this plugin.

  • Assigning a Needed Permission
    • Can Start new topics in a forum
    • Allowing users to start a new topic in a forum is controlled by their group permissions.
    • Each member group that is to have the ability start a new topic in a forum must have the permission turned on.
    • This is accomplished from the Simple:Press Administration panel Admin menu by clicking/opening Forum > Permissions > Manage Permission Sets.
    • Select “Edit Permission” for the permission set to be updated to view the “Permissions – Manage Permissions” panel.
    • Under “Creating” click the check box next to “Can start new topics in a forum” to set/enable the permission. When enabled, the check box contains a green check mark.
    • Click “Update Permission” at the bottom of the page to have the selection saved.
    • At a later time clicking the check box when it has a green check mark removes the check mark and will remove the permission when followed by clicking “Update Permission” to save the revised selection.
    • Repeat these steps on each usergroup to have this permission.

To be complete for multilingual forums, the language translation files for this plugin should be installed or downloaded/properly placed in the appropriate forum-language folder for SP plugins using one of the procedures below in the “Plugin Language Translation” section of this page.

Plugin Language Translation

A plugin may not have language translation files, but in general each Simple:Press plugin has its own language translation files each with multiple pages for translating the forum plugin’s message strings.

Forum Plugin translation files are to reside in a unique forum folder location as defined by the “Simple:Press Plugin Language Files” entry on the “Integration – Storage Locations” forum Admin panel available through the forum Admin menu at Forum > Integration > Storage Locations.

  • The default location for forum plugin translation files is the folder “…/wp-content/sp-resources/forum-language/sp-plugins”.

Information regarding downloading language files, “mo’ language file placement, and translation (language localization) is found at Localization.

WARNING: On the Localization page, the Language Translation “.mo” Files Overview should be reviewed and well understood for naming convention and language translation file placement.

More information is available regarding translation files at Simple:Press Translations. which is the repository for Simple:Press language translation files. On the base page, select the “Getting Started Guide” link for basics about it’s use. On that page, select the “register a username here” link to obtain a password to the site. Use the “Contact Form” link to request the desired language if it is not currently available. The “Contact Form” link may also be used to volunteer to be a validator for a translation project.

This plugin’s available language translation files with translation statistics, and message translations can be viewed at Answers Topic within the repository for Simple:Press language translation files.

  • Installing this Simple:Press Plugin’s Language Translation “.mo” files
    The plugin’s language translations files for each language can be correctly located in two ways.

    • Using the Admin Word:Press “Site Language” and Simple:Press “Language Translation” Features
      WARNING: On the Localization codex page, the Language Translation “.mo” Files Overview should be reviewed and well understood for naming convention and language translation file placement.
        • Under the “Language Translation Selection Sequences” heading, the “Coordinated Language Translation File Download Using the Simple:Press ‘Language Translation’ Selection” section, follow the instructions at “Adding its Translation File(s) After Downloading/Activating a Simple:Press Theme or Simple:Press Plugin”.
          • Follow the instructions to select the “Site Language” and then get to the admin page with the “Integration – Language Translations” section where there should be an entry for “Answers Topic” along with an “Install” button.
          • Click on the “Install” button for this plugin to install the language translation file for the current “Site Language” language.
            • Note: If the message “No Translation Project Exists” is displayed rather than the “Install” button, a translation file for that language could not be found in GlotPress at this time. Consider posting in the Simple:Press forum if it is felt there needs to be one added.
          • Be sure to verify the locale (filename) for the “.mo” file matches the language code for the language as referenced in the “Warning” above. If it does not, change it to match.
          • As called out in the section, continue to change the “Site Language” language and repeat the process until all desired translation files for this plugin have been installed.

       

    • Manually Finding and Storing Simple:Press Plugin’s Language Translation ‘mo’ files
    • WARNING: On the Localization codex page, the Language Translation “.mo” Files Overview should be reviewed and well understood for naming convention and language translation file placement.
      • After reviewing the material discussed under the “Language Translation Selection Sequences” heading, the “Manual Installation of Simple:Press Language Translation Files section, follow the steps outlined at “Finding and Storing ANY Simple:Press Plugin’s Language Translation ‘mo’ files”.
      • Each time through the process at the step, “Scroll down the list and click on the name of the plugin whose language files are being sought to see the translation file Version Number available”, substitute “Answers Topic” for the phrase “the name of the plugin whose language files are being sought”.
      • Be sure to verify the locale (filename) for the “.mo” file matches the language code for the language as referenced in the “Warning” above. If it does not, change it to match.
      • Repeat the steps for each language it is desired to have a translation file (french, spanish, etc.) for the plugin on the website.

Plugin Usage

Forum Admins and Moderators can mark or unmark any post as “Answers Post’.

All members with the “Can start new topics in a forum” also have the ability to mark or unmark a post as “Answers Post” within topics they originate.

  • Topic Creator, forum Admin, or Moderator Marking a Reply Post as “Answers Post”
    • Navigate to the forum topic of interest in a forum.
    • Review the reply posts to determine if any of them answers the original topic post.
    • If a reply post answers the original topic post and is not by the topic creator, click on the “Mark As Answer” button associated with the reply post.
      • The “Mark As Answer” button on the selected reply post is replaced by the “Unmark as Answer” button.
      • An icon (a check mark on a green circular background) and the message “Answers Post” is shown on the selected reply post.
      • The “Mark As Answer’ button is no longer shown on all non-topic creator reply posts in the topic.
      • On the topic’s originating post, the button “See Answer” is shown with a link to the reply post selected as answering the topic.
  • Topic Creator, forum Admin, or Moderator Unmarking a Reply Post as “Answers Post
    • Navigate to the forum topic of interest in a forum.
    • If a reply post previously marked as “Answers Post” no longer maintains that status, click on the “Unmark as Answer” button associated with the reply post to deselect it.
      • The “Unmark as Answer” button is replaced by the “Mark as Answer” button on the previous selected reply post.
      • The icon (a check mark on a green circular background) and the message “Answers Post” is no longer shown on the previously selected reply post.
      • The “Mark As Answer” button is displayed on all other reply posts in the topic that are not replies by the topic creator.
      • On the topic’s originating post, the “See Answer” button is no longer displayed.

Plugin Special Notes

If the Simple:Press MyCred Integration plugin is active, this plugin adds the ability to assign value for forum users having “Answers Post” reply posts.

  • Please see Plugin: MyCred Integration Codex page for more information on integrating the Answers Topic plugin with the Simple:Press MyCred Integration plugin.

 

Template Tags Used in the Plugin

There are three (3) template tags available for this plugin that allow further customization of the plugin’s usage in themes or otherwise customize the website. ‘sp_AnswersTopicPostIndexAnswer()’, ‘sp_AnswersTopicAnswer()’, and ‘sp_AnswersTopicSeeAnswer()’ are incorporated into standard supplied Simple:Press themes.

  • If the location of the template tags in the themes as well as the argument and parameter values for the template tags are acceptable, nothing need be done.
  • If any item relating to the template tags are to be modified or if other template tags are to be added to a theme, it is recommended that a Child or Custom theme is created first to accept the changes prior to installing this plugin.
  • In all cases the template tags should be called conditionally, if (function_exists(‘ ‘)) so that if the plugin is deactivated or does not exist, the website will continue to operate.

The Template Tag can be viewed by selecting its link below.

Action and Hooks Used in the Plugin

There are Actions and Hooks available in the Plugin’s Template Tag. The Template Tag’s Action and Hooks can be viewed by selecting its link below.

There are other Actions and Hooks available in this plugin to modify aspects of this plugin.
In file ‘sp-answers-topic-components.php‘:

  • do_action(‘sph_mark_answer_actions’, $thisTopic->user_id, $tid, true); – Hook fired after a topic in the database “xx_sftopics” table has been updated with the post ID of the post marked as “Answers Post” in the “answered” column, where “xx” is the table prefix assigned when the Simple:Press forum database was set up.
  • do_action(‘sph_unmark_answer_actions’, $thisTopic->user_id, $tid, false); – Hook fired after a topic in the database “xx_sftopics” table has been updated with a “0” (not answered) in the “answered” column, where “xx” is the table prefix assigned when the Simple:Press forum database was set up.

Plugin and Template Tag Changelog

Since Simple:Press version 5.2.3

Codex page template tags sync’d to code version 5.6.4 and plugin version 1.1.5.



Individual Template Tags


 

sp_AnswersTopicPostIndexAnswer()

Description

sp_AnswersTopicPostIndexAnswer() – This template displays a button consisting of an icon and a label to mark and unmark a post as answering the topic.

Usage

sp_AnswersTopicPostIndexAnswer($args=”, $markLabel=”, $markToolTip=”, $unmarkLabel=”, $unmarkToolTip=”);

Arguments

$args – List of arguments for controlling display.
Type:
(string) (optional)
Default:
‘tagId’ => ‘spAnswersTopicAnswersButton%ID%’
‘tagClass’ => ‘spAnswersTopicAnswersButton’
‘iconClass’ => ‘spIcon’
‘markIcon’ => ‘sp_AnswersTopicMarkButton.png’
‘unmarkIcon’ => ‘sp_AnswersTopicUnmarkButton.png’

tagId‘: CSS ID for the Div. %ID% is replaced by the post ID number.
tagClass‘: CSS Class for the Div.
iconClass‘: CSS Class for the icon.
markIcon‘: Filename of the file containing the “Mark as Answer” icon to be displayed.
unmarkIcon‘: Filename of the file containing the “Unmark as Answer” icon to be displayed.

$markLabel – Text to include along with the icon on the “Mark as Answer” button.
Type:
(string) (optional)
Default:
None

$markToolTip – Message to display in the tooltip when the “Mark as Answer” button is hovered over.
Type:
(string) (optional)
Default:
None

$unmarkLabel – Text to include along with the icon on the “Unmark as Answer” button.
Type:
(string) (optional)
Default:
None

$unmarkToolTip – Message to display in the tooltip when the “Unmark as Answer” button is hovered over.
Type:
(string) (optional)
Default:
None

Special Notes

In standard supplied Simple:Press themes this template tag is included in the forum Topic View page (‘spTopicView.php’) file.
The exceptions are:

  • the Reboot and Barebones theme where the template tag is not included in the ‘spTopicView.php’ file, but is included in the ‘spTopicViewDesktop.php’ and ‘spTopicViewMobile.php’ files.

The function is called within a conditional call of ‘sp_AnswersTopicAnswer()’, if (function_exists(‘sp_AnswersTopicAnswer’)), so that if the plugin is deactivated or does not exist, the website will continue to operate.

If the template tag is to be modified or its location on a page changed, it is suggested a Custom or Child theme be made to accept the modified template tag. Please see discussion at Template Tags Used in the Plugin.

The function requires the use of file ‘sp-answers-topic-answers-button.php’ located in the plugin’s Template Tag folder.

Examples

Display the button to mark or unmark a post as answering the topic with “tagClass” of “spButton spRight”, “$markLabel” of “Mark as Answer”, “$markToolTip” of “Mark this post as topic answer”, “$unmarkLabel” of “Unmark as Answer”, and “$unmarkToolTip” of “Unmark this post as topic answer”. Call the function within a conditional call to ‘sp_AnswersTopicAnswer()’.

if (function_exists('sp_AnswersTopicAnswer')) {
...                                            
sp_AnswersTopicPostIndexAnswer('tagClass=spButton spRight', __sp('Mark as Answer'), __sp('Mark this post as topic answer'), __sp('Unmark as Answer'), __sp('Unmark this post as topic answer'));
}

 

Actions and Hooks Used in the sp_AnswersTopicPostIndexAnswer() Template Tag

  • apply_filters(‘sph_AnswersTopicPostIndexAnswer_args’, $a) – Allows modification of the arguments to the template tag. $a contains the parsed arguments.
  • apply_filters(‘sph_AnswersTopicAnswersButton’, $out, $a) – Allows modification of the display code just prior to being output/returned. $out will contain the html display code.

Changelog

See Plugin and Template Tag Changelog for Template Tag changes and Codex page syncing to code versions.


 

sp_AnswersTopicAnswer()

Description

sp_AnswersTopicAnswer() – This template displays an icon and message on a reply post to signify the post has been selected as answering the topic. In some themes the icon is not displayed.

Usage

sp_AnswersTopicAnswer($args=”, $label=”, $toolTip=”);

Arguments

$args – List of arguments for controlling display.
Type:
(string) (optional)
Default:
‘tagId’ => ‘spAnswersTopicAnswer’
‘tagClass’ => ‘spAnswersTopicAnswer’
‘labelClass’ => ‘spInRowLabel’
‘iconClass’ => ‘spIcon’
‘icon’ => ‘sp_AnswersTopicAnswer.png’
‘stacked’ => 1

tagId‘: CSS ID for the Div.
tagClass‘: CSS Class for the Div.
labelClass‘: CSS Class for the label.
iconClass‘: CSS Class for the icon.
icon‘: Filename of the file containing the “Answers Topic” icon to be displayed.
stacked‘: Flag to indicate whether to display the label below the icon or leave them on the same line. A one (1) will show the label stacked below the icon. A zero (0) will show the icon followed by the label on the same line.

$label – Text to display along with the icon.
Type:
(string) (optional)
Default:
None

$toolTip – Message to display in the tooltip when the icon / label is hovered over.
Type:
(string) (optional)
Default:
None

Special Notes

In standard supplied Simple:Press themes this template tag is included in the forum Topic View page (‘spTopicView.php’) file.
The exceptions are:

  • the Reboot and Barebones theme where the template tag is not included in the ‘spTopicView.php’ file, but is included in the ‘spTopicViewDesktop.php’ and ‘spTopicViewMobile.php’ files.

The function is called conditionally, if (function_exists(”)), so that if the plugin is deactivated or does not exist, the website will continue to operate.

If the template tag is to be modified or its location on a page changed, it is suggested a Custom or Child theme be made to accept the modified template tag. Please see discussion at Template Tags Used in the Plugin.

The function requires the use of file ‘sp-answers-topic-answer.php’ located in the plugin’s Template Tag folder.

Examples

Display the answers topic icon with “tagClass” of “spRight”, “$label” of “Answers Post”, and “$toolTip” of “This post answers the topic”. Call the function conditionally allowing other functions within the conditional call.

if (function_exists('sp_AnswersTopicAnswer')) {
...                                            
sp_AnswersTopicAnswer('tagClass=spRight', __sp('Answers Post'), __sp('This post answers the topic'));
...
}

 

Actions and Hooks Used in the sp_AnswersTopicAnswer() Template Tag

  • apply_filters(‘sph_AnswersTopicAnswer_args’, $a) – Allows modification of the arguments to the template tag. $a contains the parsed arguments.
  • apply_filters(‘sph_AnswersTopicAnswer’, $out, $a) – Allows modification of the display code just prior to being output/returned. $out will contain the html display code.

Changelog

See Plugin and Template Tag Changelog for Template Tag changes and Codex page syncing to code versions.


 

sp_AnswersTopicSeeAnswer()

Description

sp_AnswersTopicSeeAnswer() – This template displays on the original topic post a button having an icon, a label, and a link to the reply post that is marked as answering the topic. It is only displayed if the topic is marked as answered.

Usage

sp_AnswersTopicSeeAnswer($args=”, $label=”, $toolTip=”);

Arguments

$args – List of arguments for controlling display.
Type:
(string) (optional)
Default:
‘tagId’ => ‘spAnswersTopicSeeAnswer’
‘tagClass’ => ‘spAnswersTopicSeeAnswer’
‘iconClass’ => ‘spIcon’
‘icon’ => ‘sp_AnswersTopicSeeAnswer.png’

tagId‘: CSS ID for the Div.
tagClass‘: CSS Class for the Div.
iconClass‘: CSS Class for the icon.
icon‘: ‘sp_AnswersTopicSeeAnswer.png’

$label – Text to display along with the icon on the button.
Type:
(string) (optional)
Default:
None

$toolTip – Message to display in the tooltip when the button is hovered over.
Type:
(string) (optional)
Default:
None

Special Notes

In standard supplied Simple:Press themes this template tag is included in the forum Topic View page (‘spTopicView.php’) file.
The exceptions are:

  • the Reboot and Barebones theme where the template tag is not included in the ‘spTopicView.php’ file, but is included in the ‘spTopicViewDesktop.php’ and ‘spTopicViewMobile.php’ files.

The function is called within a conditional call of ‘sp_AnswersTopicAnswer()’, if (function_exists(‘sp_AnswersTopicAnswer’)), so that if the plugin is deactivated or does not exist, the website will continue to operate.

If the template tag is to be modified or its location on a page changed, it is suggested a Custom or Child theme be made to accept the modified template tag. Please see discussion at Template Tags Used in the Plugin.

The function requires the use of file ‘sp-answers-topic-see-answer.php’ located in the plugin’s Template Tag folder.

Examples

Display the button with “tagClass” of “spAnswersTopicSeeAnswer spButton spRight”, “$label” of “See Answer”, and “$toolTip” of “Go to the post marked as the answer”. Display the button only on the first (originating) post of a topic. Call the function within a conditional call of ‘sp_AnswersTopicAnswer()’

if (function_exists('sp_AnswersTopicAnswer')) {
...                                           
if ($spThisPost->post_index == 1) sp_AnswersTopicSeeAnswer('tagClass=spAnswersTopicSeeAnswer spButton spRight', __sp('See Answer'), __sp('Go to the post marked as the answer'));
...
}

 

Actions and Hooks Used in the sp_AnswersTopicSeeAnswer() Template Tag

  • apply_filters(‘sph_AnswersTopicSeeAnswer_args’, $a) – Allows modification of the arguments to the template tag. $a contains the parsed arguments.
  • apply_filters(‘sph_AnswersTopicSeeAnswer’, $out, $a) – Allows modification of the display code just prior to being output/returned. $out will contain the html display code.

Changelog

See Plugin and Template Tag Changelog for Template Tag changes and Codex page syncing to code versions.


More Topics In SimplePress: Plugins


Copyright © 2006-2019 Simple:Press. All Rights Reserved.