diff --git a/assets/list.css b/assets/list.css index 11bd165..5f8cfd0 100644 --- a/assets/list.css +++ b/assets/list.css @@ -1,13 +1,9 @@ @charset "utf-8"; +/*** Common : START ***/ #ccc-my_favorite-list { overflow: hidden; } -#ccc-my_favorite-list .clearfix::after { - content: " "; - display: block; - clear: both; -} #ccc-my_favorite-list .header-ccc_favorite { margin-top: 1em; margin-bottom: 1em; @@ -24,42 +20,73 @@ #ccc-my_favorite-list #ccc-favorite-count .unit { font-size: 0.7em; } -#ccc-my_favorite-list .ccc-favorite-post-toggle { - margin-top: 0; -} #ccc-my_favorite-list .ccc-favorite-post-toggle > a { - color: #666; + text-decoration: none; } #ccc-my_favorite-list .ccc-favorite-post-toggle > a::before { /* icomoon Font =========== */ content: "\f056"; /* icomoon Font =========== */ } -#ccc-my_favorite-list .post-ccc_favorite { - font-size: 0; +#ccc-my_favorite-list .ccc-favorite-post-delete { + float: right; +} +/*** Common : END ***/ + + + + +/****** Style: [data-ccc_my_favorites-list-style="1"]: START ******/ +#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .clearfix::after { + content: " "; + display: block; + clear: both; +} +#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .ccc-favorite-post-toggle { + margin-top: 0; +} +#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .ccc-favorite-post-toggle > a { + color: #666; +} +#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .post-ccc_favorite { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + margin: 1.75em auto; width: calc(100% + 1%); - margin: 30px auto; - min-height: 30vh; } -#ccc-my_favorite-list .list-ccc_favorite { - font-size: 15px; - display: inline-block; - vertical-align: top; +#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .list-ccc_favorite { width: calc(20% - 1%); margin: 0 1% 1% 0; position: relative; } - - +#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .ccc-favorite-post-delete > a .text { + font-size: 0.7em; +} +#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .ccc-favorite-post-toggle { + text-align: right; + position: relative; + z-index: 10; +} +#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .ccc-favorite-post-toggle > a > .text { + display: none; +} +#ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .ccc-favorite-post-delete-button { + text-decoration: none; +} /* SP ----------------------------------------------------------*/ @media only screen and (max-width: 750px) { - #ccc-my_favorite-list .post-ccc_favorite { + #ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .post-ccc_favorite { width: calc(100% + 3%); + margin: 1.5em auto; } - #ccc-my_favorite-list .list-ccc_favorite { + #ccc-my_favorite-list[data-ccc_my_favorites-list-style="1"] .list-ccc_favorite { width: calc(50% - 3%); margin: 0 3% 3% 0; - font-size: 14px; + font-size: 0.9em; } } +/****** Style: [data-ccc_my_favorites-list-style="1"]: END ******/ diff --git a/assets/select.css b/assets/select.css index 040c15f..50ebd3d 100644 --- a/assets/select.css +++ b/assets/select.css @@ -1,6 +1,7 @@ @charset "utf-8"; @import url('./fonts.css'); +/*** Common : START ***/ .ccc-favorite-post-count > a::before, .ccc-favorite-post-toggle > a::before, .ccc-favorite-post-delete > a::before { @@ -19,9 +20,34 @@ -moz-osx-font-smoothing: grayscale; /* icomoon Font =========== */ } - +.ccc-favorite-post-toggle > a { + display: inline-block; + vertical-align: top; + box-sizing: border-box; + padding: 0 6px; + transition: all 0.3s; + text-decoration: none; +} +.ccc-favorite-post-toggle > a::before { + /* icomoon Font =========== */ + content: "\f08a"; + /* icomoon Font =========== */ +} +.ccc-favorite-post-toggle > a.save::before { + /* icomoon Font =========== */ + content: "\f004"; + /* icomoon Font =========== */ +} +.ccc-favorite-post-delete > a::before { + font-size: 18px; + display: inline-block; + vertical-align: middle; + margin-right: 0.25em; + /* icomoon Font =========== */ + content: "\f1f8"; + /* icomoon Font =========== */ +} .ccc-favorite-post-count { - float: right; transition: all 0.3s; margin-right: 12px; display: none; /* JS */ @@ -32,7 +58,7 @@ .ccc-favorite-post-count > a { display: block; box-sizing: border-box; - padding: 0 5px 0 10px; + text-decoration: none; } .ccc-favorite-post-count > a::before { font-size: 16px; @@ -49,44 +75,18 @@ font-size: 0; display: none; /* for Safari */ } +/*** Common : END ***/ + + -.ccc-favorite-post-toggle { + +/****** Style: [data-ccc_my_favorites-select_button-style="1"]: START ******/ +.ccc-favorite-post-toggle[data-ccc_my_favorites-select_button-style="1"] { text-align: right; position: relative; z-index: 10; } -.ccc-favorite-post-toggle > a { - display: inline-block; - vertical-align: top; - box-sizing: border-box; - padding: 0 6px; - transition: all 0.3s; -} -.ccc-favorite-post-toggle > a::before { - /* icomoon Font =========== */ - content: "\f08a"; - /* icomoon Font =========== */ -} -.ccc-favorite-post-toggle > a.save::before { - /* icomoon Font =========== */ - content: "\f004"; - /* icomoon Font =========== */ -} -.ccc-favorite-post-toggle > a > .text { +.ccc-favorite-post-toggle[data-ccc_my_favorites-select_button-style="1"] > a > .text { display: none; } -.ccc-favorite-post-delete { - float: right; -} -.ccc-favorite-post-delete > a .text { - font-size: 0.7em; -} -.ccc-favorite-post-delete > a::before { - font-size: 18px; - display: inline-block; - vertical-align: middle; - margin-right: 0.25em; - /* icomoon Font =========== */ - content: "\f1f8"; - /* icomoon Font =========== */ -} +/****** Style: [data-ccc_my_favorites-select_button-style="1"]: END ******/ diff --git a/assets/shortcode-list.php b/assets/shortcode-list.php index 99ff962..e7a3aae 100644 --- a/assets/shortcode-list.php +++ b/assets/shortcode-list.php @@ -13,19 +13,25 @@ class CCC_My_Favorite_ShortCode_List { public static function menu($atts) { $atts = shortcode_atts(array( "slug" => '', - "text" => '' + "text" => '', + "style" => '', ),$atts); if( $atts['slug'] ) { $slug = trim($atts['slug'], '/'); } else { - $slug = 'ccc-favorite'; + $slug = 'favorites'; } if( $atts['text'] ) { $text = $atts['text']; } else { $text = __('Favorites', CCCMYFAVORITE_TEXT_DOMAIN); } - $data = '
'.$text.'
'; // + if( $atts['style'] or $atts['style'] === 0 or $atts['style'] === '0' ) { + $style = $atts['style']; + } else { + $style = 1; + } + $data = '
'.$text.'
'; // return $data; } //endfunction @@ -33,6 +39,7 @@ public static function results($atts) { $atts = shortcode_atts(array( "class" => '', "posts_per_page" => '', + "style" => '', ),$atts); if( $atts['class'] ) { $class = 'class="'.$atts['class'].'"'; @@ -44,7 +51,12 @@ public static function results($atts) { } else { $posts_per_page = 100; } - $data = '
'; // + if( $atts['style'] or $atts['style'] === 0 or $atts['style'] === '0' ) { + $style = $atts['style']; + } else { + $style = 1; + } + $data = '
'; // return $data; } //endfunction diff --git a/assets/shortcode-select.php b/assets/shortcode-select.php index 3232dd3..0054b3e 100644 --- a/assets/shortcode-select.php +++ b/assets/shortcode-select.php @@ -12,7 +12,8 @@ class CCC_My_Favorite_ShortCode_Select { public static function button($atts) { $atts = shortcode_atts(array( "post_id" => '', - "text" => '' + "text" => '', + "style" => '', ),$atts); if( $atts['post_id'] ) { $post_id = intval($atts['post_id']); @@ -25,7 +26,12 @@ public static function button($atts) { } else { $text = __('Favorite', CCCMYFAVORITE_TEXT_DOMAIN); } - $data = '
'.$text.'
'; // + if( $atts['style'] or $atts['style'] === 0 or $atts['style'] === '0' ) { + $style = $atts['style']; + } else { + $style = 1; + } + $data = '
'.$text.'
'; // return $data; } //endfunction diff --git a/my-favorites.php b/my-favorites.php index e840fae..17520cb 100644 --- a/my-favorites.php +++ b/my-favorites.php @@ -2,8 +2,8 @@ /** * Plugin Name: My Favorites * Plugin URI: https://wordpress.org/plugins/my-favorites/ - * Description: Saving a user's favorite posts and displaying it a list. - * Version: 1.0.0 + * Description: Save user's favorite posts and list them. + * Version: 1.1.0 * Requires at least: 4.8 * Requires PHP: 5.4.0 * Author: Takashi Matsuyama @@ -53,9 +53,9 @@ function ccc_my_favorite_initialize() { /*** How to use this Shortcode ***/ /* - * [ccc_my_favorite_select_button post_id="int" text="string"] - * [ccc_my_favorite_list_menu slug="string" text="string"] - * [ccc_my_favorite_list_results class="string"] + * [ccc_my_favorite_select_button post_id="int" text="string" style=""] + * [ccc_my_favorite_list_menu slug="string" text="string" style=""] + * [ccc_my_favorite_list_results class="string" style=""] */ require( CCCMYFAVORITE_PLUGIN_PATH .'/assets/shortcode-select.php' ); require( CCCMYFAVORITE_PLUGIN_PATH .'/assets/shortcode-list.php' ); diff --git a/readme.txt b/readme.txt index bfd112c..f99a8cf 100644 --- a/readme.txt +++ b/readme.txt @@ -5,29 +5,31 @@ Tags: favorites, likes, accessibility, favorite posts Requires at least: 4.8 Tested up to: 5.6 Requires PHP: 5.4.0 -Stable tag: 1.0.0 +Stable tag: 1.1.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html -Saving a user's favorite posts and displaying it a list. +Save user's favorite posts and list them. == Description == -Saving a user's favorite posts and displaying it a list. -This plugin is simple. You can save the user's favorite posts just a install and display it anywhere you want with just a shortcode. +Save user's favorite posts and list them. +This plugin is simple. You can save the user's favorite posts just a install and display them anywhere you want with just a shortcode. The logged-in user's data is saved in the user meta. Other user's data is saved to Web Storage (localStorage). -'[ccc_my_favorite_select_button post_id="int" text="string"]' -'[ccc_my_favorite_list_menu slug="string" text="string"]' -'[ccc_my_favorite_list_results class="string"]' +== Usage == +* **Shortcode:** `[ccc_my_favorite_select_button post_id="" style=""]` +* **Shortcode:** `[ccc_my_favorite_list_menu slug="" text="" style=""]` +* **Shortcode:** `[ccc_my_favorite_list_results class="" style=""]` + +For pages with a shortcode for list view ([ccc_my_favorite_list_results]), set the slug to "favorites" or the page template file name to "ccc-favorite.php". == Installation == 1. Upload `my-favorites` to the `/wp-content/plugins/` directory. 2. Activate the plugin through the 'Plugins' menu in WordPress. 3. Use shortcodes to display the favorite posts list and an icon for save and a menu for link to list. -4. For pages with a shortcode for list view ([ccc_my_favorite_list_results]), set the slug to "favorite" or the page template file name to "ccc-favorite.php". == Screenshots == @@ -35,5 +37,11 @@ The logged-in user's data is saved in the user meta. Other user's data is saved == Changelog == += 1.1.0 = +Add shortcode attribute (`style=""`) and modify CSS. + += 1.0.1 = +Modify default slug of shortcode (`[ccc_my_favorite_list_menu slug=""]`) to "favorites" from "ccc-favorite" and modify readme.txt, description. + = 1.0.0 = Initial release.