Plugin Directory

Changeset 1859900


Ignore:
Timestamp:
04/17/2018 05:17:48 PM (8 years ago)
Author:
c.laborier
Message:

Preparing v1.4.0

Location:
ripple-by-wowmotion/trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • ripple-by-wowmotion/trunk/admin/admin.php

    r1835116 r1859900  
    11<?php
    22
     3require_once(RIPPLE_DIR_PATH . '/admin/class/class.dashboard-admin.php');
    34require_once(RIPPLE_DIR_PATH . '/admin/class/class.breadcrumbs-admin.php');
    45require_once(RIPPLE_DIR_PATH . '/admin/class/class.semantic-related-content-admin.php');
     
    1213class RippleAdmin
    1314{
    14 
    1515    /**
    1616     * Start up
     
    2121    {
    2222        // Ripple admin script management
    23         function ripple_admin_scripts() {
     23        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    2424
     25        // Settings menu creation
     26        add_action( 'admin_menu', array( $this, 'render_menu' ) );
     27
     28        // Initializing sub-modules
     29        $this->initialize_ripple_modules();
     30    }
     31
     32    /**
     33     * Global admin style and scripts (used by every plugin module/widget)
     34     */
     35    public function enqueue_scripts()
     36    {
     37        // Load the scripts on only the plugin admin page
     38        if ($this->is_plugin_page())
     39        {
    2540            /**
    2641             * Vendors
    2742             */
     43            // jQuery-ui components
     44            wp_enqueue_script('jquery-ui-tabs');
     45            wp_register_style('jquery-ui-tabs', 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css', [], RIPPLE_VERSION);
     46            wp_enqueue_style('jquery-ui-tabs');
     47
    2848            // Fontawesome
    2949            wp_register_style('fontawesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
     
    3151
    3252            // Pretty checkbox
     53            // TODO : migrate to latest version
    3354            wp_register_style('pretty-checkbox', "https://cdnjs.cloudflare.com/ajax/libs/pretty-checkbox/2.2.1/pretty.min.css");
    3455            wp_enqueue_style('pretty-checkbox');
     
    4566            wp_enqueue_script('ripple-admin-script', RIPPLE_DIR_URL . 'admin/js/admin.js', array('jquery'), RIPPLE_VERSION, true);
    4667
     68        }
     69    }
    4770
    48         }
    49         add_action( 'admin_enqueue_scripts', 'ripple_admin_scripts' );
     71    /**
     72     * The function return true if the current page belong to the plugin (false otherwise)
     73     * @return bool
     74     */
     75    private function is_plugin_page()
     76    {
     77        // Get the sub-modules identifier which are useful to detect if the current admin page belong to the plugin or not
     78        $plugin_page_slugs = [
     79            RippleDashboardAdmin::OPTION_NAME,
     80            RippleBreadcrumbsAdmin::OPTION_NAME,
     81            RippleRelatedContentAdmin::OPTION_NAME,
     82            RippleHierarchicalRelatedContentAdmin::OPTION_NAME,
     83            RippleSocialSharingAdmin::OPTION_NAME
     84        ];
    5085
    51         // Settings menu creation
    52         add_action( 'admin_menu', array( $this, 'render_menu' ) );
     86        // Load the scripts on only the plugin admin page
     87        return (isset($_GET['page']) && (in_array($_GET['page'], $plugin_page_slugs))) ;
     88
    5389    }
    5490
     
    6399            __("Ripple", RIPPLE_TR_DOMAIN),
    64100            "manage_options",
    65             "ripple_admin"
    66             //array( $this, 'render_page' )
     101            "ripple_admin" // This ID should be the same as the first page of the admin menu
    67102        );
    68 
    69         $this->initializing_ripple_module();
    70     }
    71 
    72     /**
    73      * Not use for now.
    74      */
    75     public function render_page(){
    76         ?>
    77         <div class="wrap">
    78             <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
    79         </div>
    80         <?php
    81103    }
    82104
     
    84106     * Initializing ripple modules
    85107     */
    86     private function initializing_ripple_module()
     108    public function initialize_ripple_modules()
    87109    {
     110        $ripple_dashboard = RippleDashboardAdmin::getInstance();
     111        $ripple_dashboard->set_up();
     112
    88113        $ripple_related_content = RippleRelatedContentAdmin::getInstance();
    89114        $ripple_related_content->set_up();
     
    103128     * @param $file_path
    104129     * @return String - The Dynamic file content
     130     * TODO : move this to RippleHelper class
    105131     */
    106132    public static function load_partial($file_path)
     
    115141}
    116142
    117 // Initializing the class if the user reach the administration panel
    118 if( is_admin() ) {
    119     $ripple_admin = new RippleAdmin();
    120 }
  • ripple-by-wowmotion/trunk/admin/class/class.admin-options-manager.php

    r1835234 r1859900  
    88 * - Generate the HTML name of the form inputs
    99 */
     10// TODO this class can evolve to provide a method to generate the option HTML field
    1011class AdminOptionManager {
    1112
    12     private $options;
    13     private $admin_page_id;
    14     private $default_options;
     13    private $option_slug;
    1514
    1615    /**
     16     * The constuctor only ask for the slug of the option.
     17     * This slug will be used to create a new entry in the Wp "options" table
    1718     * @var $option_name
    1819     */
    19     public function __construct($admin_page_id)
     20    public function __construct($option_slug)
    2021    {
    21         $this->admin_page_id = $admin_page_id;
     22        // The admin page id is used to set an option entry in the WP option table
     23        $this->option_slug = $option_slug;
    2224
    23         // Get options for the current admin module
    24         $this->options = get_option( $admin_page_id );
    25 
    26         // Store the default options for the admin page
    27         $this->default_options = ripple_get_default_options()[$admin_page_id];
     25        // Create the option if it doesn't exist yet on the WP side
     26        $this->create_option();
    2827    }
    2928
     29    /**
     30     * Create the option in the Wp option table if it does not exist
     31     */
     32    private function create_option()
     33    {
     34        $current_option = $this->get_options();
     35        if(!$current_option || empty($current_option)){
     36            update_option($this->option_slug, $this->get_default_option());
     37        }
     38    }
     39
     40    /**
     41     * Retrieve the default value to store in the option
     42     */
     43    private function get_default_option()
     44    {
     45        $ripple_default_options = unserialize(RIPPLE_DEFAULT_OPTIONS);
     46        return isset($ripple_default_options[$this->option_slug]) ? $ripple_default_options[$this->option_slug] : [];
     47
     48    }
     49
     50    /**
     51     * Return the actual registered option
     52     * @return mixed
     53     */
    3054    public function get_options(){
    31         return $this->options;
     55        $options = get_option( $this->option_slug );
     56        if($options){
     57            return $options;
     58        }
     59        return false;
     60    }
     61
     62    /**
     63     * This function allow to store values under the "option_slug" option of the Wp table
     64     * Type of value :
     65     * - The value to store can be either a scalar value (a String a serialize object)
     66     * - Or it can be an array. In such a case, the method apply a merge with the value already stored and the new value.
     67     * @param mixed $to_store - The new value to store
     68     * @return bool
     69     */
     70    public function store_option($to_store)
     71    {
     72        $option = is_array($to_store) ? array_replace_recursive($this->get_options(), $to_store) : $to_store;
     73        return update_option($this->option_slug, $option);
    3274    }
    3375
    3476    /**
    3577     * This method allow to build an input html name/id based on several parameters
     78     * The option named return will look like :
     79     *   ->   "the_option_slug['param1]['param2']['param3]"
     80     * If no parameters given, the method simply the option_slug as the HTML name
     81     * @return String
    3682     */
    3783    public function html_name()
    3884    {
    39         // The method need at least one arguments
     85        $html_name = $this->option_slug;
    4086        if (func_num_args() > 0) {
    41             $html_name = $this->admin_page_id;
    4287            for ($i = 0; $i < func_num_args(); $i++) {
    4388                $args = func_get_arg($i);
    4489                $html_name .= "[{$args}]";
    4590            }
    46             return $html_name;
    4791        }
    48         return false;
     92        return $html_name;
    4993    }
    5094
     
    63107        if (func_num_args() > 0) {
    64108            // Get the options container where to find the specific options
    65             $tmp_options = $this->options;
     109            $tmp_options = $this->get_options();
    66110            // Browsing the options tree arguments by arguments
    67111            for ($i = 0; $i < func_num_args(); $i++) {
  • ripple-by-wowmotion/trunk/admin/class/class.breadcrumbs-admin.php

    r1835234 r1859900  
    1818    public function set_up()
    1919    {
    20         /**
    21          * Admin page action management
    22          */
    23         $this->render_menu();
     20        // Rendering menu
     21        add_action( 'admin_menu', array( $this, 'render_menu' ) );
     22
     23        // Registering action
    2424        add_action( 'admin_init', array( $this, 'register_settings' ) );
    2525
     
    5353
    5454            <div class="ripple-admin-page-intro">
    55                 <p><?php _e('Ripple ease the way to generate and display a breadcrumb inside your pages.', RIPPLE_TR_DOMAIN);?> </p>
    56                 <p><?php _e('The breadcrumbs will help your visitors for a better navigation and will improve your SEO performances.', RIPPLE_TR_DOMAIN);?></p>
     55                <p>
     56                    <?php _e('Ripple ease the way to generate and display a breadcrumb inside your pages.', RIPPLE_TR_DOMAIN);?> <br />
     57                    <?php _e('The breadcrumbs will help your visitors for a better navigation and will improve your SEO performances.', RIPPLE_TR_DOMAIN);?>
     58                </p>
     59                <br />
     60                <?php _e('Activate this widget and you will be able to use it in two different ways :', RIPPLE_TR_DOMAIN);?>
     61                <ul>
     62                    <li><?php _e('By activating configuring the automatic display', RIPPLE_TR_DOMAIN);?></li>
     63                    <li>
     64                        <?php
     65                        _e('By using the shortcode', RIPPLE_TR_DOMAIN);
     66
     67                        $help_title = 'Breadcrumbs widget shortcode';
     68                        $help_content = RippleAdmin::load_partial(RIPPLE_DIR_PATH . '/admin/partials/_help_breadcrumbs_widget_shortcode.html.php');
     69                        ?>
     70                        <a href="#" class="help-link swal-help-link" data-title="<?php echo $help_title; ?>" data-content="<?php echo htmlspecialchars($help_content) ?>">
     71                            <i class="fa fa-question-circle"></i>
     72                            <?php _e('Learn how to use the shortcode', RIPPLE_TR_DOMAIN);?>
     73                        </a>
     74                    </li>
     75                </ul>
    5776            </div>
    5877
     
    83102                    </div>
    84103                    <div class="ripple-section-intro">
    85                         <?php _e('You can choose to display the breadcrumb automatically, or by using the dedicated shortcode :', RIPPLE_TR_DOMAIN);?>
    86                         <ul>
    87                             <li><?php _e('Automatic display : the breadcrumbs will appear right before the content of your pages.', RIPPLE_TR_DOMAIN);?></li>
    88                             <li><?php _e('Display with shortcode : place the shortcode <strong>[ripple_breadcrumbs]</strong> wherever you want inside your page. ', RIPPLE_TR_DOMAIN);?></li>
    89                         </ul>
     104                        <strong><?php _e('Notice for shortcode', RIPPLE_TR_DOMAIN); ?></strong> <br />
     105                        <?php _e('Be aware that when using the shortcode, if you do not parametrize it, the default value considered will be the set of options bellow', RIPPLE_TR_DOMAIN); ?>
    90106                    </div>
    91107                    <div id="breadcrumbs-toggle-form" class="toggle-form">
     
    118134                                    $value     = $this->option_manager->option_value("separator");
    119135                                    ?>
    120                                     <input type="text" id="separator" name="<?php echo $html_name; ?>" value="<?php echo $value; ?>" autocomplete="off" />
    121                                     <br />
    122                                     <label for="separator"><?php _e("Will appear between each link of the breadcrumb", RIPPLE_TR_DOMAIN); ?></label>
     136                                    <input type="text" id="separator" name="<?php echo $html_name; ?>" value="<?php echo $value; ?>" autocomplete="off" size="50" />
     137                                    <br />
     138                                    <label for="separator"><?php _e("Will appear between each link of the breadcrumb. The value can be text or HTML.", RIPPLE_TR_DOMAIN); ?></label>
    123139                                </td>
    124140                            </tr>
     
    205221        $new_input['automatic_display'] = isset($input['automatic_display']); // Boolean settings
    206222
     223        // Separator can be text or HTML
    207224        if( isset( $input['separator'] ) ) {
    208             $new_input['separator'] = sanitize_text_field($input['separator']);
     225            $new_input['separator'] = esc_textarea($input['separator']);
    209226        }
    210227
  • ripple-by-wowmotion/trunk/admin/class/class.hierarchical-related-content-admin.php

    r1835234 r1859900  
    1818    public function set_up()
    1919    {
    20         /**
    21          * Admin page action management
    22          */
    23         $this->render_menu();
     20        // Rendering menu
     21        add_action( 'admin_menu', array( $this, 'render_menu' ) );
     22
     23        // Registering options
    2424        add_action( 'admin_init', array( $this, 'register_settings' ) );
    2525
     
    6767                        $help_content = RippleAdmin::load_partial(RIPPLE_DIR_PATH . '/admin/partials/_help_hierarchical_widget_shortcode.html.php');
    6868                        ?>
    69                         <a href="#" class="swal-help-link" data-title="<?php echo $help_title; ?>" data-content="<?php echo htmlspecialchars($help_content) ?>">
     69                        <a href="#" class="help-link swal-help-link" data-title="<?php echo $help_title; ?>" data-content="<?php echo htmlspecialchars($help_content) ?>">
    7070                            <i class="fa fa-question-circle"></i>
    7171                            <?php _e('Learn how to use the shortcode', RIPPLE_TR_DOMAIN);?>
  • ripple-by-wowmotion/trunk/admin/class/class.semantic-related-content-admin.php

    r1835234 r1859900  
    1010    /**
    1111     * Allow to manipulate options for the admin page with ease
     12     * @var AdminOptionManager
    1213     */
    1314    private $option_manager;
     
    1819    public function set_up()
    1920    {
    20         /**
    21          * Admin page action management
    22          */
    23         $this->render_menu();
     21        // Rendering submenu
     22        add_action("admin_menu", [$this, "render_menu"]);
     23
     24        // Registering settings
    2425        add_action( 'admin_init', array( $this, 'register_settings' ) );
    2526
     
    3839            __("Semantic related content", RIPPLE_TR_DOMAIN),
    3940            'manage_options',
    40             "ripple_admin", // Change this for 'self::OPTION_NAME' to have a separate page available for the plugin
     41            self::OPTION_NAME,
    4142            array( $this, 'render_page' )
    4243        );
     
    6970                        $help_content = RippleAdmin::load_partial(RIPPLE_DIR_PATH . '/admin/partials/_help_semantic_widget_shortcode.html.php');
    7071                        ?>
    71                         <a href="#" class="swal-help-link" data-title="<?php echo $help_title; ?>" data-content="<?php echo htmlspecialchars($help_content) ?>">
     72                        <a href="#" class="help-link swal-help-link" data-title="<?php echo $help_title; ?>" data-content="<?php echo htmlspecialchars($help_content) ?>">
    7273                            <i class="fa fa-question-circle"></i>
    7374                            <?php _e('Learn how to use the shortcode', RIPPLE_TR_DOMAIN);?>
     
    7576                    </li>
    7677                </ul>
    77 
    7878            </div>
    7979
     
    337337    public function sanitize( $input )
    338338    {
    339 
    340339        $new_input = array();
    341340
  • ripple-by-wowmotion/trunk/admin/class/class.social-sharing-admin.php

    r1835116 r1859900  
    1818    public function set_up()
    1919    {
    20         /**
    21          * Admin page action management
    22          */
    23         $this->render_menu();
     20        // Rendering the menu
     21        add_action( 'admin_menu', array( $this, 'render_menu' ) );
     22
     23        // Registering settings
    2424        add_action( 'admin_init', array( $this, 'register_settings' ) );
    2525
  • ripple-by-wowmotion/trunk/admin/css/admin.css

    r1835116 r1859900  
    66    margin: 0 0 20px 0;
    77}
     8
     9
     10#ripple-admin-wrapper a.help-link{
     11    color:#ffffff;
     12    border-radius: 3px;
     13    background: #049ee8;
     14    padding: 4px 10px 4px 10px;
     15    font-size: 0.8em;
     16    text-decoration: none;
     17    cursor: pointer;
     18}
     19
     20
     21#ripple-admin-wrapper a.help-link:hover{
     22    opacity:0.8;
     23}
     24
     25#ripple-admin-wrapper .ripple-admin-section a.help-link{
     26    background: #777777;
     27}
     28
    829
    930
     
    2344    font-size: 22px;
    2445    font-weight: normal;
     46}
     47
     48section.ripple-admin-section .ripple-section-content{
     49    margin: 20px 0 20px 0;
    2550}
    2651
     
    123148}
    124149
    125 
    126 a.swal-help-link{
    127     color:#ffffff;
    128     border-radius: 3px;
    129     background: #049ee8;
    130     padding: 4px 10px 4px 10px;
    131     font-size: 0.8em;
    132     text-decoration: none;
    133     cursor: pointer;
    134 }
    135 
    136 a.swal-help-link:hover{
    137     opacity:0.8;
    138 }
    139 
    140150.swal2-content table{
    141151    width: 100%;
  • ripple-by-wowmotion/trunk/config.php

    r1835116 r1859900  
    2020define('RIPPLE_DEFAULT_OPTIONS', serialize(
    2121    array(
    22         "ripple_options" => array(
     22        "ripple_options" => [
    2323            "version" => RIPPLE_VERSION,
    24         ),
     24        ],
     25        "ripple_admin" => [ // Dashboard options
     26            "post_type" => []
     27        ],
    2528        "ripple_breadcrumbs" => [
    2629            "activated"         => true,
  • ripple-by-wowmotion/trunk/includes/class.breadcrumbs-widget.php

    r1835234 r1859900  
    1212        add_action( 'wp_enqueue_scripts', array($this, 'ripple_breadcrumbs_scripts') );
    1313
    14         // Managing automatic display
    15         add_filter('the_content', array( $this, 'automatic_display' ));
     14        // If the widget is not activated, doing nothing more
     15        if( !$this->options["activated"] ){ return; }
    1616
    17         // Managing shortcode
    18         add_shortcode('ripple_breadcrumbs', array($this, 'shortcode_display'));
     17        // Managing automatic display if activated
     18        if( $this->options["automatic_display"] )
     19        {
     20            add_filter('the_content', array( $this, 'do_the_content_filter' ));
     21        }
     22    }
    1923
     24
     25    public static function get_shortcode_name()
     26    {
     27        return 'ripple_breadcrumbs';
    2028    }
    2129
    2230    /**
     31     * @return String|void
     32     */
     33    public function do_shortcode()
     34    {
     35        // Display the breadcrumbs only when the widget is activated
     36        if( !$this->options["activated"] ){ return false; }
     37
     38        return $this->build_breadcrumbs_html();
     39    }
     40
     41
     42    /**
    2343     * Called when initializing the widget to display the breadcrumbs right before the page content
    24      * @param $content
     44     * Should be called only within the worpdress filter "the_content"
     45     * @param $content - The page content
    2546     * @return string
    2647     */
    27     public function automatic_display($content)
     48    public function do_the_content_filter($content)
    2849    {
    29         // Display the breadcrumb only when the widget is activated or if the display is forced
    30         if( !$this->options["automatic_display"] ){ return $content; }
     50        if(in_the_loop()){
    3151
    32         // Display the breadcrumb only within the main query
    33         if( !is_main_query()){ return $content;}
     52            // Display the breadcrumb only within the main query
     53            if( !is_main_query()){ return $content;}
    3454
    35         // Do not display the breadcrumbs on homepage
    36         if ( is_front_page() ) { return $content; }
     55            // Do not display the breadcrumbs on homepage
     56            if ( is_front_page() ) { return $content; }
    3757
    38         return $this->build_breadcrumbs_html().$content;
     58            return $this->build_breadcrumbs_html().$content;
     59        }
    3960    }
    4061
     
    4465        wp_enqueue_style('ripple-breadcrumbs-style');
    4566    }
    46 
    47     public function shortcode_display($atts = [], $content = null)
    48     {
    49         if(!$this->options["activated"]){ return ''; }
    50 
    51         return $this->build_breadcrumbs_html();
    52     }
    53 
    5467
    5568    /**
     
    7184    {
    7285        $breadcrumbs = "";
     86        $item_pos = 1; // Item_pos will be automatically incremented by the get_item method
    7387
    74         // Retrieve the current queried object (can be a page, a post, an archive etc. ...)
    75         $current_wp_object = get_queried_object();
     88        // Retrieve the current post (can be a page, a post, an archive etc. ...)
     89        $current_post = get_post();
    7690
    7791        // Initializing some stuffs based on the registered options
     
    8094        // Build home link
    8195        if($display_home_link){
    82             $breadcrumbs .= $this->get_item("home", get_home_url(), $this->options["home_link_text"]);
     96            $breadcrumbs .= $this->get_item("home", get_home_url(), $this->options["home_link_text"], $item_pos);
    8397        }
    8498
    85         // Breadcrumbs for standard page
    86         if( is_page() ) {
     99        // Breadcrumbs for hierarchical content
     100
     101        if(is_post_type_hierarchical( get_post_type() ))
     102        {
    87103            // If child page, get parents
    88             $ancestors = get_post_ancestors($current_wp_object->ID);
     104            $ancestors = get_post_ancestors($current_post->ID);
    89105
    90106            if (count($ancestors)) {
     
    94110                // Build the breadcrumb
    95111                foreach ($ancestors as $ancestor_id) {
    96                     $breadcrumbs .= $this->get_item($ancestor_id,  get_permalink($ancestor_id), get_the_title($ancestor_id));
     112                    $breadcrumbs .= $this->get_item($ancestor_id,  get_permalink($ancestor_id), get_the_title($ancestor_id), $item_pos);
    97113                }
    98114            }
    99115        }
    100 
    101 
    102         $breadcrumbs .= $this->get_current_item();
    103 
     116        // Last but not least, the current page
     117        $breadcrumbs .= $this->get_item(get_the_ID(), "", get_the_title(), $item_pos, true);
    104118        return $this->wrap_breadcrumbs_content($breadcrumbs);
    105119    }
     
    110124     * @var $permalink - The URL of the content
    111125     * @var $link_text - The text to display
     126     * @var $position - The position of the element in the breadcrumbs
     127     * @var $is_current - Determine if we are dealing with the element of the breadcrumbs corresponding to the current page
    112128     * @return String
    113129     */
    114     private function get_item($content_id, $permalink, $link_text)
     130    private function get_item($content_id, $permalink="", $link_text, &$position, $is_current = false)
    115131    {
    116         $link = "<a class='bread-parent' href='{$permalink}'>{$link_text}</a>";
    117         return $this->wrap_item($content_id, $link);
    118     }
    119 
    120     /**
    121      * Build the HTML element corresponding to the current item of the breadcrumbs (current page)
    122      */
    123     private function get_current_item()
    124     {
    125         $the_title = get_the_title();
    126         $item = "<span class='ripple-breadcrumbs-current-item'>{$the_title}</span>";
    127         return $this->wrap_item("current", $item, false);
     132        $seo_attr = "itemscope itemtype='http://schema.org/Thing' itemprop='item'";
     133        if($is_current){
     134            $item = "<span {$seo_attr} class='ripple-breadcrumbs-current-item' itemprop='name'><span itemprop=\"name\">{$link_text}</span></span>";
     135            return $this->wrap_item("current", $item, $position, false);
     136        }
     137        $link = "<a {$seo_attr} class='bread-parent' href='{$permalink}'><span itemprop=\"name\">{$link_text}</span></a>";
     138        $wrapped_item = $this->wrap_item($content_id, $link, $position);
     139        $position ++;
     140        return $wrapped_item;
    128141    }
    129142
     
    132145     * @var $content_id String - Will be used to add an additional css class on the li class
    133146     * @var $item String - The HTML representing the item
     147     * @var $position
    134148     * @var $with_separator
    135149     * @return String - The generated HTML
    136150     */
    137     private function wrap_item($content_id, $item, $with_separator = true)
     151    private function wrap_item($content_id, $item, $position, $with_separator = true)
    138152    {
    139         $html = "<li class='ripple-breadcrumb-item-{$content_id} ripple-breadcrumb-item'>{$item}</li>";
    140         if($with_separator) {
    141             $html .= "<li class='ripple-breadcrumb-separator-{$content_id} ripple-breadcrumb-separator'>{$this->options['separator']}</li>";
    142         }
     153        $separator = $with_separator ? htmlspecialchars_decode($this->options['separator']) : "";
     154        $seo_attr = " itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem' ";
     155        $html =
     156            "<li {$seo_attr} class='ripple-breadcrumb-item-{$content_id} ripple-breadcrumb-item'>
     157                {$item}<meta itemprop='position' content='{$position}' />
     158            </li>{$separator}";
    143159        return $html;
    144160    }
     
    150166    private function wrap_breadcrumbs_content($breadcrumbs)
    151167    {
    152         return "<ul class='ripple-breadcrumbs'>{$breadcrumbs}</ul>";
     168        $seo_attr = "itemscope itemtype='http://schema.org/BreadcrumbList'";
     169        return "<ol {$seo_attr} class='ripple-breadcrumbs' >{$breadcrumbs}</ol>";
    153170    }
    154171
  • ripple-by-wowmotion/trunk/includes/class.hierarchical-related-content-widget.php

    r1835234 r1859900  
    2828
    2929        // Displaying the widget only on "page" content
    30         if (is_page()) {
     30        $current_post_type = get_post_type_object(get_post_type());
     31        if ($current_post_type->hierarchical) {
    3132
    3233            // Forcing some other options
     
    4041                'child_of' => get_the_ID(),
    4142                'parent' => get_the_ID(),
     43                'post_type'    => $current_post_type->name,
    4244                'hierarchical' => 0,
    4345                'sort_column' => 'menu_order',
  • ripple-by-wowmotion/trunk/includes/class.semantic-related-content-searcher.php

    r1835234 r1859900  
    4141        /**
    4242         * Searching all related content based on taxonomy comparison
     43         * TODO : filter the taxonomies (we want the pubic one
    4344         */
    4445        $taxonomies = get_taxonomies();
  • ripple-by-wowmotion/trunk/includes/class.semantic-related-content-widget.php

    r1835234 r1859900  
    3838    {
    3939        // run only for single post page
    40         if (is_single() && in_the_loop() && is_main_query()) {
    41 
     40        // TODO : review the condition. Also, adapt it for other widget
     41        if (is_single() && in_the_loop() && is_main_query())
     42        {
    4243            $related_posts = $this->get_related_posts(get_the_ID());
    4344
  • ripple-by-wowmotion/trunk/public/css/ripple-breadcrumbs.css

    r1835234 r1859900  
    33    line-height: 30px;
    44    overflow:hidden;
    5     padding: 0;
     5    padding: 5px;
    66    margin: 0;
     7}
     8
     9.ripple-breadcrumbs li:nth-child(1){
     10    margin-left: 0;
    711}
    812
    913.ripple-breadcrumbs li{
    1014    display:inline-block;
    11     margin-right:10px;
     15    margin: 3px 10px;
    1216}
    1317
  • ripple-by-wowmotion/trunk/readme.txt

    r1835238 r1859900  
    22
    33Contributors: Christophe Laborier
    4 Tags: related content, similar content, related post, similar post, social share, social sharing, social buttons, share buttons, share, social networks, breadcrumbs
     4Tags: related content, hierarchical related content, semantic related content, hierarchical, semantic, related post, social sharing, breadcrumbs
    55Requires at least: 4.6
    6 Tested up to: 4.7.2
    7 Stable tag: 1.3.1
     6Tested up to: 4.9.5
     7Stable tag: 1.4.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1212
    1313== Description ==
     14
     15= Ripple Dashboard =
     16
     17Ripple widgets works under certain conditions which are determined by your Wordpress post types configuration.
     18That's why Ripple offer you an easy way to make the necessary changes on your post types so you can use Ripple the best way.
     19
     20Ripple allows you to :
     21
     22* Make a post type hierarchical or not
     23* Activate/deactivate the WP core taxonomies ("category", "post_tag") for every post type
     24* Activate/deactivate the custom taxonomies for custom post type
    1425
    1526= Ripple semantic related contents =
     
    2334* Choose between the automatic display to display the widget right after the post content or use the shortcode to display it whereever you want
    2435
     36Note : this widget only works for post type with registered taxonomies.
     37
    2538= Ripple hierarchical related contents =
    2639
     
    3144* Choose between the automatic display to display the widget right after the post content or use the shortcode to display it whereever you want
    3245
     46Note : this widget only works for hierarchical post type.
     47
    3348= Ripple breadcrumbs =
    3449
     
    3853* Choose the separator between every breadcrumbs link
    3954* Choose to display the home link or not
    40 * Choose between the automatic display to display the widget right after the post content or use the shortcode to display it whereever you want
     55* Choose between the automatic display to display the widget right after the post content or use the shortcode to display it wherever you want
     56
     57Notice that the breadcrumb is SEO friendly as it is build using Breadcrumbs markup
     58More information here about markups here : https://developers.google.com/search/docs/data-types/breadcrumb
     59
     60Note : this widget only works for hierarchical post type.
    4161
    4262= Ripple social share =
  • ripple-by-wowmotion/trunk/ripple.php

    r1835238 r1859900  
    33Plugin Name: Ripple
    44Description: Generate more traffic and time spent on your website by inviting users to read similar contents and share them on social networks.
    5 Version: 1.3.1
     5Version: 1.4.0
    66Author: Christophe Laborier
    77Author URI:
     
    1616require_once(dirname(__FILE__) . '/functions.php');
    1717
     18require_once(dirname(__FILE__) . '/includes/class.ripple-helper.php');
     19require_once(dirname(__FILE__) . '/includes/class.ripple-middleware.php');
     20
    1821require_once(dirname(__FILE__) . '/admin/class/class.migration.php');
    1922
    20 
     23require_once(dirname(__FILE__) . '/includes/class.ripple.php');
    2124require_once(dirname(__FILE__) . '/admin/admin.php');
    2225
     
    2831
    2932
    30 class Ripple
    31 {
    32     private $social_widget;
     33// Activate the Ripple Middleware to configure Worpdress depending on Ripple options
     34// This activation is required both for front and admin page
     35RippleMiddleware::configure_wordpress();
    3336
    34     public function __construct()
    35     {
    36         // Initializing social manager widget
    37         // TODO : refactor this plugin the same way the other (
    38         $this->social_widget = new RippleSocialWidget(ripple_get_social_sharing_options());
    39 
    40         // Creating the instance of the breadcrumbs widgets
    41         new RippleBreadcrumbWidget(ripple_get_breadcrumbs_options());
    42 
    43         // Creating the instance of the semantic related content widgets
    44         new RippleSemanticRelatedContentWidget(ripple_get_sementic_related_content_options());
    45         add_shortcode(RippleSemanticRelatedContentWidget::get_shortcode_name(), array($this, 'do_ripple_semantic_related_content_shortcode'));
    46 
    47         // Creating the instance of the hierarchical related content widgets
    48         new RippleHierarchicalRelatedContentWidget(ripple_get_hierarchical_related_content_options());
    49         add_shortcode(RippleHierarchicalRelatedContentWidget::get_shortcode_name(), array($this, 'do_ripple_hierarchical_related_content_shortcode'));
    50 
    51         /*************************************
    52          * PLUGIN STANDARD METHOD
    53          ************************************/
    54 
    55         register_activation_hook  (__FILE__, 'Ripple::ripple_on_activate');
    56         register_deactivation_hook(__FILE__, 'Ripple::ripple_on_deactivate');
    57 
    58         /*************************************
    59          * ACTIONS & FILTERS
    60          ************************************/
    61 
    62         add_action('plugins_loaded', array( $this, 'ripple_plugins_loaded' ));
    63 
    64         // Uncomment this to activate tag and category taxonomies on pages
    65         // add_action( 'init', [$this, 'activate_page_taxonomy'] );
    66 
    67     }
    68 
    69     /**
    70      * Executed when using the semantic widget shortcode
    71      * @param array $atts
    72      * @param null $content
    73      * @return String
    74      */
    75     public function do_ripple_semantic_related_content_shortcode($atts = [], $content = null)
    76     {
    77         $widget_options = $this->normalize_shortocde_atts(ripple_get_sementic_related_content_options(), $atts);
    78         $widget = new RippleSemanticRelatedContentWidget($widget_options);
    79         return $widget->get_related_posts_html();
    80     }
    81 
    82     /**
    83      * Executed when using the hierarchical widget shortcode
    84      * @param array $atts
    85      * @param null $content
    86      * @return String
    87      */
    88     public function do_ripple_hierarchical_related_content_shortcode($atts = [], $content = null)
    89     {
    90         $widget_options = $this->normalize_shortocde_atts(ripple_get_hierarchical_related_content_options(), $atts);
    91         $widget = new RippleHierarchicalRelatedContentWidget($widget_options);
    92         return $widget->get_related_posts_html();
    93     }
    94 
    95     /**
    96      * Normalize attributes given when calling a shortcode and combine them with the default values
    97      * in order to have a complete set of attribute required for the shortcode usage
    98      * @param $default_atts
    99      * @param array $atts
    100      * @return array
    101      */
    102     private function normalize_shortocde_atts($default_atts, $atts = [])
    103     {
    104         // normalize attribute keys, lowercase
    105         $atts = array_change_key_case((array)$atts, CASE_LOWER);
    106 
    107         // override default attributes with user attributes
    108         $atts = shortcode_atts($default_atts, $atts);
    109 
    110         return $atts;
    111     }
    112 
    113     /**
    114      * Function called after plugin is loaded
    115      */
    116     public function ripple_plugins_loaded()
    117     {
    118         // Adding social bar to the current content
    119         add_filter('the_content', array($this, 'ripple_initialize_social_widget' ));
    120     }
    121 
    122     /**
    123      * Function called when activating the plugin
    124      */
    125     public static function ripple_on_activate()
    126     {
    127         // Running migration before defining default
    128         $migration = RippleMigration::getInstance();
    129         $migration->migrate();
    130     }
    131 
    132     /**
    133      * Function called when deactivating the plugin
    134      */
    135     public static function ripple_on_deactivate(){}
    136 
    137     public function ripple_initialize_social_widget($content)
    138     {
    139         return $this->social_widget->add_social_widget($content);
    140     }
    141 
    142     /**
    143      * Activate post_tag and category taxonomie on pages
    144      */
    145     function activate_page_taxonomy()
    146     {
    147         // Activate post_tag taxonomy on page
    148         register_taxonomy_for_object_type('post_tag', 'page');
    149 
    150         // Activate category taxonomy on page
    151         register_taxonomy_for_object_type('category', 'page');
    152     }
    153 
    154 
    155 
     37if(!is_admin()) {
     38    // Initialize Ripple for the front pages
     39    new Ripple();
    15640}
    157 
    158 // Activating everything
    159 $my_settings_page = new Ripple();
     41else{
     42    // Initialize the Ripple admin panels
     43    new RippleAdmin();
     44}
Note: See TracChangeset for help on using the changeset viewer.