Plugin Directory

Changeset 1379595


Ignore:
Timestamp:
03/26/2016 11:25:24 PM (10 years ago)
Author:
toddnestor
Message:

now we are up to 1.2.3 and this one should be more stable

Location:
hercules-sentiment-analysis
Files:
110 added
9 edited

Legend:

Unmodified
Added
Removed
  • hercules-sentiment-analysis/trunk/hercules-framework/core/HercAbstract.php

    r1379594 r1379595  
    5252    }
    5353
     54    /**
     55     * Turns a string into Upper Camelcase.
     56     * @param $string string to upper cammel case.
     57     * @return string upper camel-cased version of input string.
     58     */
    5459    function UpperCamelCaseIt( $string )
    5560    {
     
    5762    }
    5863
     64    /**
     65     * Turns an upper camel-cased string into a slug with lowercase letters and hyphens for word splits.
     66     * @param $string Upper camel-cased string to turn into a slug.
     67     * @return string slugified version of the upper camel case input string.
     68     */
    5969    function SlugifyCamelCase( $string )
    6070    {
     
    7080    }
    7181
     82    /**
     83     * Takes a class name from a class that uses this framework and turns it into a slug.
     84     * @param $string Class name that is of the type HercView_something, HercModel_something, HercController_something, or HercHelper_something.
     85     * @return bool|string slugified version of the class name if there was one, otherwise returns false.
     86     */
    7287    function SlugFromClassName( $string )
    7388    {
     
    8095    }
    8196
     97    /**
     98     * Returns the slug for the current class instance.
     99     *
     100     * @return bool|string Slugified version of the class name if it knows the class, otherwise false.
     101     */
    82102    function CurrentSlug()
    83103    {
     
    137157    }
    138158
     159    /**
     160     * Returns the url to a specific file.
     161     * @param string $file
     162     * @return string url to the file supplied.
     163     */
    139164    function GetUrl( $file = '' )
    140165    {
     
    142167    }
    143168
     169    /**
     170     * Returns the path to the main plugin folder for this plugin.
     171     *
     172     * @return string path to the plugin folder.
     173     */
    144174    function GetPluginDirectory()
    145175    {
    146         return dirname( dirname( __FILE__ ) );
    147     }
    148 
     176        return dirname( dirname( dirname( __FILE__ ) ) );
     177    }
     178
     179    /**
     180     * Returns the path to the Hercules Framework.
     181     *
     182     * @return string path to the framework parent folder.
     183     */
     184    function GetFrameworkDirectory()
     185    {
     186        return dirname( dirname( __FILE__ ) );
     187    }
     188
     189    /**
     190     * Returns the folder name for the plugin folder for this plugin.
     191     *
     192     * @return string folder name for this plugin.
     193     */
    149194    function GetPluginFolderName()
    150195    {
     
    155200    }
    156201
     202    /**
     203     * Returns the folder name for the framework folder.
     204     *
     205     * @return string folder name for this framework.
     206     */
     207    function GetFrameworkFolderName()
     208    {
     209        $plugin_folder = $this->GetFrameworkDirectory();
     210        $folder_bits = explode( DIRECTORY_SEPARATOR, $plugin_folder );
     211
     212        return array_pop( $folder_bits );
     213    }
     214
     215    /**
     216     * Returns the current page url based on / instead of having the domain.
     217     * @return string
     218     */
    157219    function GetCurrentPage()
    158220    {
     
    172234    }
    173235
     236    /**
     237     * Adds data to the data array if it existed, otherwise makes a new data array from the input value.
     238     *
     239     * @param array $data array of data to add to the current data array.
     240     */
    174241    function AddToData( $data )
    175242    {
     
    180247            $this->data = array( $this->data );
    181248
    182         $this->data = array_merge( $this->data, $data );
     249        if( is_array( $this->data ) && is_array( $data ) && !empty( $data ) )
     250            $this->data = array_merge( $this->data, $data );
    183251    }
    184252}
  • hercules-sentiment-analysis/trunk/hercules-framework/core/Model.php

    r1379591 r1379595  
    88    }
    99
     10    /**
     11     * Saves the custom settings for the current model when a post is saved.
     12     *
     13     * @param $post_id WP will supply the post id for the current post being saved.
     14     */
    1015    function RegisterPostMetaSave( $post_id )
    1116    {
     
    1419    }
    1520
     21    /**
     22     * Sets the functions that need to be run when WP is initialized.
     23     */
    1624    function Initialize()
    1725    {
     
    1927            add_action( 'save_post', array( $this, 'RegisterPostMetaSave' ) );
    2028
    21         $this->UpdateOptions();
     29        if( property_exists( $this, 'has_options' ) && !empty( $this->has_options ) )
     30            $this->UpdateOptions();
    2231    }
    2332
     33    /**
     34     * Gets post meta related to the current model
     35     * @param $post_id Id of post to get meta data for.
     36     * @return mixed all the meta data for the current model on the provided post.
     37     */
    2438    function GetMeta( $post_id )
    2539    {
     
    2741    }
    2842
     43    /**
     44     * Gets options for the current model.
     45     *
     46     * @return mixed all the options related to the current model.
     47     */
    2948    function GetOptions()
    3049    {
     
    3251    }
    3352
     53    /**
     54     * Gets individual option from the current model.
     55     * @param $key Option to get value from.
     56     * @return bool|mixed false if no value found, otherwise the option value for the provided key.
     57     */
    3458    function GetOption( $key )
    3559    {
     
    3963            return !empty( $options[ $key ] ) ? $options[ $key ] : false;
    4064        else
    41             return $options;
     65            return false;
    4266    }
    4367
     68    /**
     69     * Updates all the options for the current model if there is any post or get data.
     70     */
    4471    function UpdateOptions()
    4572    {
  • hercules-sentiment-analysis/trunk/hercules-framework/core/View.php

    r1379591 r1379595  
    1919    }
    2020
     21    /**
     22     * This is the core view function, it actually renders stuff to the page using the Handlebars template engine.
     23     *
     24     * This will also add the class name to all form inputs so that form data is an array of data based on the current class name.
     25     *
     26     * @param array $data data to be used when rendering.
     27     * @param bool|false $return If set to true then it will return the html for rendering rather than echoing it out.
     28     * @return null|string no return value if $return is set to false, otherwise the html string that is created during rendering.
     29     */
    2130    function Render( $data = array(), $return = false )
    2231    {
     
    7382    }
    7483
     84    /**
     85     * Creates the name attribute for form inputs based on the current class.
     86     * @param $matches array of matches provided by a preg_replace_callback function
     87     * @return string name attribute with the classname[] thrown around the original name.
     88     */
    7589    function AddClassNameToPostNames( $matches )
    7690    {
     
    91105    }
    92106
     107    /**
     108     * Registers all scripts for the current view.
     109     */
    93110    function RegisterAllScripts()
    94111    {
     
    124141    }
    125142
     143    /**
     144     * Enqueues bootstrap which only works inside of .herc-bootstrap sections so that we don't interfere with other styles.
     145     */
    126146    function EnqueueBootstrap()
    127147    {
    128         $this->EnqueueStyleSheet( 'assets/css/bootstrap.css', sanitize_title( $this->GetPluginFolderName() . '_bootstrap' ) );
    129     }
    130 
     148        $this->EnqueueStyleSheet( $this->GetFrameworkFolderName() . '/assets/css/bootstrap.css', sanitize_title( $this->GetFrameworkFolderName() . '_bootstrap' ) );
     149    }
     150
     151    /**
     152     * Registers the enqueue bootstrap function so it enqueues in the admin area and the public side.
     153     */
    131154    function IncludeBootstrap()
    132155    {
     
    135158    }
    136159
     160    /**
     161     * Registers metaboxes to be rendered on post edit screens.
     162     */
    137163    function RegisterMetaboxes()
    138164    {
     
    154180    }
    155181
     182    /**
     183     * Adds the view to the post content if it is a post add on.
     184     * @param $content post content provided by WP.
     185     * @return string the new post content with the view added on.
     186     */
    156187    function PostFilter( $content )
    157188    {
     
    169200    }
    170201
     202    /**
     203     * Generates data to be used when rendering.
     204     */
    171205    function GenerateData()
    172206    {
     
    205239    }
    206240
     241    /**
     242     * Registers an options page if this is an options page view.
     243     */
    207244    function AddOptionsPage()
    208245    {
     
    215252    }
    216253
     254    /**
     255     * Adds columns to the posts lists tables if applicable for this view.
     256     * @param $columns WP provided array of columns already being rendered.
     257     * @return array columns array with our new columns added on.
     258     */
    217259    function AddPostColumns( $columns )
    218260    {
     
    222264    }
    223265
     266    /**
     267     * Adds columns to the comments list table if applicable for this view.
     268     * @param $columns WP provided array of columns already being rendered.
     269     * @return array columns array with our new columns added on.
     270     */
    224271    function AddCommentColumns( $columns )
    225272    {
     
    229276    }
    230277
     278    /**
     279     * Calculates the value for the current custom column if applicable.
     280     *
     281     * @param $colname name of the column currently being rendered.
     282     * @param $post_id id of the post that is being rendered.
     283     */
    231284    function PostColumnValues( $colname, $post_id )
    232285    {
     
    253306    }
    254307
     308    /**
     309     * Calculates the value for the current custom column if applicable.
     310     *
     311     * @param $colname name of the column currently being rendered.
     312     * @param $post_id id of the comment that is being rendered.
     313     */
    255314    function CommentColumnValues( $colname, $post_id )
    256315    {
     
    278337    }
    279338
     339    /**
     340     * Adds an admin page to WP if this is an admin page view.
     341     */
    280342    function AddAdminPage()
    281343    {
     
    291353    }
    292354
     355    /**
     356     * Registers a short code to be used in WP.
     357     * @param array $attributes provided by WP, it is the attributes added to the shortcode.
     358     * @return string HTML string of the rendered view.
     359     */
    293360    public function RegisterShortcode( $attributes = array() )
    294361    {
     
    296363    }
    297364
     365    /**
     366     * Handles all the code that needs to be handled each time WP is initialized.
     367     */
    298368    function Initialize()
    299369    {
     
    339409    }
    340410
     411    /**
     412     * Handles adding columns and functions to process values for those columns to post list tables.
     413     *
     414     * @param $post_type string of the post type to process actions for.
     415     */
    341416    function RegisterPostColumn( $post_type )
    342417    {
  • hercules-sentiment-analysis/trunk/models/sentiment-analysis/sentiment-analysis.php

    r1379591 r1379595  
    1414
    1515    /**
    16      * Approves all positive comments, and marks comments as having been processed so we don't process the same comments multiple times.
     16     * Processes comments based on settings.  Auto approves positive comments if that setting is set, unapproves negative comments if that setting is set.
    1717     */
    18     public function ApprovePositiveComments()
     18    public function HandleComments()
    1919    {
    2020        $comments = get_comments( array( 'status' => 'hold', 'meta_query' => array( array( 'key' => 'sentiment-checked', 'compare' => 'NOT EXISTS' ) ) ) );
     
    4545
    4646        if( $this->Model('settings')->GetOption('auto_approve_positive_comments') == 'yes' || $this->Model('settings')->GetOption('auto_unapprove_negative_comments') == 'yes' )
    47             add_action( 'init', array( $this, 'ApprovePositiveComments' ) );
     47            add_action( 'init', array( $this, 'HandleComments' ) );
    4848    }
    4949}
  • hercules-sentiment-analysis/trunk/models/settings/settings.php

    r1379591 r1379595  
    99        $this->class_name = __CLASS__;
    1010        $this->directory = dirname( __FILE__ );
     11        $this->has_options = true;
    1112
    1213        parent::__construct();
  • hercules-sentiment-analysis/trunk/plugin.php

    r1379594 r1379595  
    55Author: Todd D. Nestor - todd.nestor@gmail.com
    66Author URI: http://toddnestor.com
    7 Version: 1.2.1
     7Version: 1.2.2
    88License: GNU General Public License v3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
  • hercules-sentiment-analysis/trunk/readme.txt

    r1379594 r1379595  
    44Requires at least: 3.5
    55Tested up to: 4.3
    6 Stable tag: 1.2.1
     6Stable tag: 1.2.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • hercules-sentiment-analysis/trunk/views/settings/settings.php

    r1379591 r1379595  
    1414        $this->priority   = 5;
    1515
     16        //Bootstrap makes things awesome!
    1617        $this->IncludeBootstrap();
    1718
  • hercules-sentiment-analysis/trunk/views/settings/template.php

    r1379591 r1379595  
    66                {{#if updated}}
    77                <div class="row">
    8                     <div class="col-md-6">
     8                    <div class="col-md-12">
    99                        <div class="alert alert-success" role="alert"><strong>Success!</strong> Your settings were updated!</div>
    1010                    </div>
Note: See TracChangeset for help on using the changeset viewer.