Changeset 1859900
- Timestamp:
- 04/17/2018 05:17:48 PM (8 years ago)
- Location:
- ripple-by-wowmotion/trunk
- Files:
-
- 15 edited
-
admin/admin.php (modified) (9 diffs)
-
admin/class/class.admin-options-manager.php (modified) (2 diffs)
-
admin/class/class.breadcrumbs-admin.php (modified) (5 diffs)
-
admin/class/class.hierarchical-related-content-admin.php (modified) (2 diffs)
-
admin/class/class.semantic-related-content-admin.php (modified) (6 diffs)
-
admin/class/class.social-sharing-admin.php (modified) (1 diff)
-
admin/css/admin.css (modified) (3 diffs)
-
config.php (modified) (1 diff)
-
includes/class.breadcrumbs-widget.php (modified) (8 diffs)
-
includes/class.hierarchical-related-content-widget.php (modified) (2 diffs)
-
includes/class.semantic-related-content-searcher.php (modified) (1 diff)
-
includes/class.semantic-related-content-widget.php (modified) (1 diff)
-
public/css/ripple-breadcrumbs.css (modified) (1 diff)
-
readme.txt (modified) (5 diffs)
-
ripple.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ripple-by-wowmotion/trunk/admin/admin.php
r1835116 r1859900 1 1 <?php 2 2 3 require_once(RIPPLE_DIR_PATH . '/admin/class/class.dashboard-admin.php'); 3 4 require_once(RIPPLE_DIR_PATH . '/admin/class/class.breadcrumbs-admin.php'); 4 5 require_once(RIPPLE_DIR_PATH . '/admin/class/class.semantic-related-content-admin.php'); … … 12 13 class RippleAdmin 13 14 { 14 15 15 /** 16 16 * Start up … … 21 21 { 22 22 // Ripple admin script management 23 function ripple_admin_scripts() {23 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 24 24 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 { 25 40 /** 26 41 * Vendors 27 42 */ 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 28 48 // Fontawesome 29 49 wp_register_style('fontawesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'); … … 31 51 32 52 // Pretty checkbox 53 // TODO : migrate to latest version 33 54 wp_register_style('pretty-checkbox', "https://cdnjs.cloudflare.com/ajax/libs/pretty-checkbox/2.2.1/pretty.min.css"); 34 55 wp_enqueue_style('pretty-checkbox'); … … 45 66 wp_enqueue_script('ripple-admin-script', RIPPLE_DIR_URL . 'admin/js/admin.js', array('jquery'), RIPPLE_VERSION, true); 46 67 68 } 69 } 47 70 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 ]; 50 85 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 53 89 } 54 90 … … 63 99 __("Ripple", RIPPLE_TR_DOMAIN), 64 100 "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 67 102 ); 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 <?php81 103 } 82 104 … … 84 106 * Initializing ripple modules 85 107 */ 86 p rivate function initializing_ripple_module()108 public function initialize_ripple_modules() 87 109 { 110 $ripple_dashboard = RippleDashboardAdmin::getInstance(); 111 $ripple_dashboard->set_up(); 112 88 113 $ripple_related_content = RippleRelatedContentAdmin::getInstance(); 89 114 $ripple_related_content->set_up(); … … 103 128 * @param $file_path 104 129 * @return String - The Dynamic file content 130 * TODO : move this to RippleHelper class 105 131 */ 106 132 public static function load_partial($file_path) … … 115 141 } 116 142 117 // Initializing the class if the user reach the administration panel118 if( is_admin() ) {119 $ripple_admin = new RippleAdmin();120 } -
ripple-by-wowmotion/trunk/admin/class/class.admin-options-manager.php
r1835234 r1859900 8 8 * - Generate the HTML name of the form inputs 9 9 */ 10 // TODO this class can evolve to provide a method to generate the option HTML field 10 11 class AdminOptionManager { 11 12 12 private $options; 13 private $admin_page_id; 14 private $default_options; 13 private $option_slug; 15 14 16 15 /** 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 17 18 * @var $option_name 18 19 */ 19 public function __construct($ admin_page_id)20 public function __construct($option_slug) 20 21 { 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; 22 24 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(); 28 27 } 29 28 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 */ 30 54 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); 32 74 } 33 75 34 76 /** 35 77 * 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 36 82 */ 37 83 public function html_name() 38 84 { 39 // The method need at least one arguments85 $html_name = $this->option_slug; 40 86 if (func_num_args() > 0) { 41 $html_name = $this->admin_page_id;42 87 for ($i = 0; $i < func_num_args(); $i++) { 43 88 $args = func_get_arg($i); 44 89 $html_name .= "[{$args}]"; 45 90 } 46 return $html_name;47 91 } 48 return false;92 return $html_name; 49 93 } 50 94 … … 63 107 if (func_num_args() > 0) { 64 108 // Get the options container where to find the specific options 65 $tmp_options = $this-> options;109 $tmp_options = $this->get_options(); 66 110 // Browsing the options tree arguments by arguments 67 111 for ($i = 0; $i < func_num_args(); $i++) { -
ripple-by-wowmotion/trunk/admin/class/class.breadcrumbs-admin.php
r1835234 r1859900 18 18 public function set_up() 19 19 { 20 / **21 * Admin page action management22 */ 23 $this->render_menu();20 // Rendering menu 21 add_action( 'admin_menu', array( $this, 'render_menu' ) ); 22 23 // Registering action 24 24 add_action( 'admin_init', array( $this, 'register_settings' ) ); 25 25 … … 53 53 54 54 <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> 57 76 </div> 58 77 … … 83 102 </div> 84 103 <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); ?> 90 106 </div> 91 107 <div id="breadcrumbs-toggle-form" class="toggle-form"> … … 118 134 $value = $this->option_manager->option_value("separator"); 119 135 ?> 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> 123 139 </td> 124 140 </tr> … … 205 221 $new_input['automatic_display'] = isset($input['automatic_display']); // Boolean settings 206 222 223 // Separator can be text or HTML 207 224 if( isset( $input['separator'] ) ) { 208 $new_input['separator'] = sanitize_text_field($input['separator']);225 $new_input['separator'] = esc_textarea($input['separator']); 209 226 } 210 227 -
ripple-by-wowmotion/trunk/admin/class/class.hierarchical-related-content-admin.php
r1835234 r1859900 18 18 public function set_up() 19 19 { 20 / **21 * Admin page action management22 */ 23 $this->render_menu();20 // Rendering menu 21 add_action( 'admin_menu', array( $this, 'render_menu' ) ); 22 23 // Registering options 24 24 add_action( 'admin_init', array( $this, 'register_settings' ) ); 25 25 … … 67 67 $help_content = RippleAdmin::load_partial(RIPPLE_DIR_PATH . '/admin/partials/_help_hierarchical_widget_shortcode.html.php'); 68 68 ?> 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) ?>"> 70 70 <i class="fa fa-question-circle"></i> 71 71 <?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 10 10 /** 11 11 * Allow to manipulate options for the admin page with ease 12 * @var AdminOptionManager 12 13 */ 13 14 private $option_manager; … … 18 19 public function set_up() 19 20 { 20 / **21 * Admin page action management22 */ 23 $this->render_menu();21 // Rendering submenu 22 add_action("admin_menu", [$this, "render_menu"]); 23 24 // Registering settings 24 25 add_action( 'admin_init', array( $this, 'register_settings' ) ); 25 26 … … 38 39 __("Semantic related content", RIPPLE_TR_DOMAIN), 39 40 'manage_options', 40 "ripple_admin", // Change this for 'self::OPTION_NAME' to have a separate page available for the plugin41 self::OPTION_NAME, 41 42 array( $this, 'render_page' ) 42 43 ); … … 69 70 $help_content = RippleAdmin::load_partial(RIPPLE_DIR_PATH . '/admin/partials/_help_semantic_widget_shortcode.html.php'); 70 71 ?> 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) ?>"> 72 73 <i class="fa fa-question-circle"></i> 73 74 <?php _e('Learn how to use the shortcode', RIPPLE_TR_DOMAIN);?> … … 75 76 </li> 76 77 </ul> 77 78 78 </div> 79 79 … … 337 337 public function sanitize( $input ) 338 338 { 339 340 339 $new_input = array(); 341 340 -
ripple-by-wowmotion/trunk/admin/class/class.social-sharing-admin.php
r1835116 r1859900 18 18 public function set_up() 19 19 { 20 / **21 * Admin page action management22 */ 23 $this->render_menu();20 // Rendering the menu 21 add_action( 'admin_menu', array( $this, 'render_menu' ) ); 22 23 // Registering settings 24 24 add_action( 'admin_init', array( $this, 'register_settings' ) ); 25 25 -
ripple-by-wowmotion/trunk/admin/css/admin.css
r1835116 r1859900 6 6 margin: 0 0 20px 0; 7 7 } 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 8 29 9 30 … … 23 44 font-size: 22px; 24 45 font-weight: normal; 46 } 47 48 section.ripple-admin-section .ripple-section-content{ 49 margin: 20px 0 20px 0; 25 50 } 26 51 … … 123 148 } 124 149 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 140 150 .swal2-content table{ 141 151 width: 100%; -
ripple-by-wowmotion/trunk/config.php
r1835116 r1859900 20 20 define('RIPPLE_DEFAULT_OPTIONS', serialize( 21 21 array( 22 "ripple_options" => array(22 "ripple_options" => [ 23 23 "version" => RIPPLE_VERSION, 24 ), 24 ], 25 "ripple_admin" => [ // Dashboard options 26 "post_type" => [] 27 ], 25 28 "ripple_breadcrumbs" => [ 26 29 "activated" => true, -
ripple-by-wowmotion/trunk/includes/class.breadcrumbs-widget.php
r1835234 r1859900 12 12 add_action( 'wp_enqueue_scripts', array($this, 'ripple_breadcrumbs_scripts') ); 13 13 14 // Managing automatic display15 add_filter('the_content', array( $this, 'automatic_display' ));14 // If the widget is not activated, doing nothing more 15 if( !$this->options["activated"] ){ return; } 16 16 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 } 19 23 24 25 public static function get_shortcode_name() 26 { 27 return 'ripple_breadcrumbs'; 20 28 } 21 29 22 30 /** 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 /** 23 43 * 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 25 46 * @return string 26 47 */ 27 public function automatic_display($content)48 public function do_the_content_filter($content) 28 49 { 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()){ 31 51 32 // Display the breadcrumb only within the main query33 if( !is_main_query()){ return $content;}52 // Display the breadcrumb only within the main query 53 if( !is_main_query()){ return $content;} 34 54 35 // Do not display the breadcrumbs on homepage36 if ( is_front_page() ) { return $content; }55 // Do not display the breadcrumbs on homepage 56 if ( is_front_page() ) { return $content; } 37 57 38 return $this->build_breadcrumbs_html().$content; 58 return $this->build_breadcrumbs_html().$content; 59 } 39 60 } 40 61 … … 44 65 wp_enqueue_style('ripple-breadcrumbs-style'); 45 66 } 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 54 67 55 68 /** … … 71 84 { 72 85 $breadcrumbs = ""; 86 $item_pos = 1; // Item_pos will be automatically incremented by the get_item method 73 87 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(); 76 90 77 91 // Initializing some stuffs based on the registered options … … 80 94 // Build home link 81 95 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); 83 97 } 84 98 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 { 87 103 // If child page, get parents 88 $ancestors = get_post_ancestors($current_ wp_object->ID);104 $ancestors = get_post_ancestors($current_post->ID); 89 105 90 106 if (count($ancestors)) { … … 94 110 // Build the breadcrumb 95 111 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); 97 113 } 98 114 } 99 115 } 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); 104 118 return $this->wrap_breadcrumbs_content($breadcrumbs); 105 119 } … … 110 124 * @var $permalink - The URL of the content 111 125 * @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 112 128 * @return String 113 129 */ 114 private function get_item($content_id, $permalink , $link_text)130 private function get_item($content_id, $permalink="", $link_text, &$position, $is_current = false) 115 131 { 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; 128 141 } 129 142 … … 132 145 * @var $content_id String - Will be used to add an additional css class on the li class 133 146 * @var $item String - The HTML representing the item 147 * @var $position 134 148 * @var $with_separator 135 149 * @return String - The generated HTML 136 150 */ 137 private function wrap_item($content_id, $item, $ with_separator = true)151 private function wrap_item($content_id, $item, $position, $with_separator = true) 138 152 { 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}"; 143 159 return $html; 144 160 } … … 150 166 private function wrap_breadcrumbs_content($breadcrumbs) 151 167 { 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>"; 153 170 } 154 171 -
ripple-by-wowmotion/trunk/includes/class.hierarchical-related-content-widget.php
r1835234 r1859900 28 28 29 29 // 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) { 31 32 32 33 // Forcing some other options … … 40 41 'child_of' => get_the_ID(), 41 42 'parent' => get_the_ID(), 43 'post_type' => $current_post_type->name, 42 44 'hierarchical' => 0, 43 45 'sort_column' => 'menu_order', -
ripple-by-wowmotion/trunk/includes/class.semantic-related-content-searcher.php
r1835234 r1859900 41 41 /** 42 42 * Searching all related content based on taxonomy comparison 43 * TODO : filter the taxonomies (we want the pubic one 43 44 */ 44 45 $taxonomies = get_taxonomies(); -
ripple-by-wowmotion/trunk/includes/class.semantic-related-content-widget.php
r1835234 r1859900 38 38 { 39 39 // 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 { 42 43 $related_posts = $this->get_related_posts(get_the_ID()); 43 44 -
ripple-by-wowmotion/trunk/public/css/ripple-breadcrumbs.css
r1835234 r1859900 3 3 line-height: 30px; 4 4 overflow:hidden; 5 padding: 0;5 padding: 5px; 6 6 margin: 0; 7 } 8 9 .ripple-breadcrumbs li:nth-child(1){ 10 margin-left: 0; 7 11 } 8 12 9 13 .ripple-breadcrumbs li{ 10 14 display:inline-block; 11 margin -right:10px;15 margin: 3px 10px; 12 16 } 13 17 -
ripple-by-wowmotion/trunk/readme.txt
r1835238 r1859900 2 2 3 3 Contributors: Christophe Laborier 4 Tags: related content, similar content, related post, similar post, social share, social sharing, social buttons, share buttons, share, social networks, breadcrumbs4 Tags: related content, hierarchical related content, semantic related content, hierarchical, semantic, related post, social sharing, breadcrumbs 5 5 Requires at least: 4.6 6 Tested up to: 4. 7.27 Stable tag: 1. 3.16 Tested up to: 4.9.5 7 Stable tag: 1.4.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 12 12 13 13 == Description == 14 15 = Ripple Dashboard = 16 17 Ripple widgets works under certain conditions which are determined by your Wordpress post types configuration. 18 That'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 20 Ripple 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 14 25 15 26 = Ripple semantic related contents = … … 23 34 * Choose between the automatic display to display the widget right after the post content or use the shortcode to display it whereever you want 24 35 36 Note : this widget only works for post type with registered taxonomies. 37 25 38 = Ripple hierarchical related contents = 26 39 … … 31 44 * Choose between the automatic display to display the widget right after the post content or use the shortcode to display it whereever you want 32 45 46 Note : this widget only works for hierarchical post type. 47 33 48 = Ripple breadcrumbs = 34 49 … … 38 53 * Choose the separator between every breadcrumbs link 39 54 * 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 57 Notice that the breadcrumb is SEO friendly as it is build using Breadcrumbs markup 58 More information here about markups here : https://developers.google.com/search/docs/data-types/breadcrumb 59 60 Note : this widget only works for hierarchical post type. 41 61 42 62 = Ripple social share = -
ripple-by-wowmotion/trunk/ripple.php
r1835238 r1859900 3 3 Plugin Name: Ripple 4 4 Description: 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.15 Version: 1.4.0 6 6 Author: Christophe Laborier 7 7 Author URI: … … 16 16 require_once(dirname(__FILE__) . '/functions.php'); 17 17 18 require_once(dirname(__FILE__) . '/includes/class.ripple-helper.php'); 19 require_once(dirname(__FILE__) . '/includes/class.ripple-middleware.php'); 20 18 21 require_once(dirname(__FILE__) . '/admin/class/class.migration.php'); 19 22 20 23 require_once(dirname(__FILE__) . '/includes/class.ripple.php'); 21 24 require_once(dirname(__FILE__) . '/admin/admin.php'); 22 25 … … 28 31 29 32 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 35 RippleMiddleware::configure_wordpress(); 33 36 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 37 if(!is_admin()) { 38 // Initialize Ripple for the front pages 39 new Ripple(); 156 40 } 157 158 // Activating everything 159 $my_settings_page = new Ripple(); 41 else{ 42 // Initialize the Ripple admin panels 43 new RippleAdmin(); 44 }
Note: See TracChangeset
for help on using the changeset viewer.