Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
Add shortcode attribute (`style=""`) and modify CSS.
  • Loading branch information
takashi-matsuyama committed May 3, 2021
1 parent 7f902ea commit 6ce3f7f
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 78 deletions.
71 changes: 49 additions & 22 deletions assets/list.css
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 ******/
74 changes: 37 additions & 37 deletions assets/select.css
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 */
Expand All @@ -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;
Expand All @@ -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 ******/
20 changes: 16 additions & 4 deletions assets/shortcode-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,33 @@ 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 = '<div class="ccc-favorite-post-count"><a href="'.esc_url( home_url() ).'/'.$slug.'/"><span class="num"></span><span class="text">'.$text.'</span></a></div>'; //<!-- /.ccc-favorite-post-count -->
if( $atts['style'] or $atts['style'] === 0 or $atts['style'] === '0' ) {
$style = $atts['style'];
} else {
$style = 1;
}
$data = '<div class="ccc-favorite-post-count" data-ccc_my_favorites-menu-style="'.$style.'"><a href="'.esc_url( home_url() ).'/'.$slug.'/"><span class="num"></span><span class="text">'.$text.'</span></a></div>'; //<!-- /.ccc-favorite-post-count -->
return $data;
} //endfunction

public static function results($atts) {
$atts = shortcode_atts(array(
"class" => '',
"posts_per_page" => '',
"style" => '',
),$atts);
if( $atts['class'] ) {
$class = 'class="'.$atts['class'].'"';
Expand All @@ -44,7 +51,12 @@ public static function results($atts) {
} else {
$posts_per_page = 100;
}
$data = '<div id="ccc-my_favorite-list" data-ccc_my_favorite-posts_per_page="'.$posts_per_page.'" '.$class.'></div>'; //<!-- /#ccc-my_favorite-list -->
if( $atts['style'] or $atts['style'] === 0 or $atts['style'] === '0' ) {
$style = $atts['style'];
} else {
$style = 1;
}
$data = '<div id="ccc-my_favorite-list" data-ccc_my_favorites-list-style="'.$style.'" data-ccc_my_favorite-posts_per_page="'.$posts_per_page.'" '.$class.'></div>'; //<!-- /#ccc-my_favorite-list -->
return $data;
} //endfunction

Expand Down
10 changes: 8 additions & 2 deletions assets/shortcode-select.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand All @@ -25,7 +26,12 @@ public static function button($atts) {
} else {
$text = __('Favorite', CCCMYFAVORITE_TEXT_DOMAIN);
}
$data = '<div class="ccc-favorite-post-toggle"><a href="#" class="ccc-favorite-post-toggle-button" data-post_id-ccc_favorite="'.$post_id.'"><span class="text">'.$text.'</span></a></div>'; //<!-- /.ccc-favorite-post-toggle -->
if( $atts['style'] or $atts['style'] === 0 or $atts['style'] === '0' ) {
$style = $atts['style'];
} else {
$style = 1;
}
$data = '<div class="ccc-favorite-post-toggle" data-ccc_my_favorites-select_button-style="'.$style.'"><a href="#" class="ccc-favorite-post-toggle-button" data-post_id-ccc_favorite="'.$post_id.'"><span class="text">'.$text.'</span></a></div>'; //<!-- /.ccc-favorite-post-toggle -->
return $data;
} //endfunction

Expand Down
10 changes: 5 additions & 5 deletions my-favorites.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' );
Expand Down
24 changes: 16 additions & 8 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,43 @@ 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 ==



== 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.

0 comments on commit 6ce3f7f

Please sign in to comment.