-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: add client-side favorite management * feat: switch icon * feat: load resources via WP API on favorites page * feat: use cookies instead of localStorage to allow server-side retrieval * feat: add AJAX backend to update resource favorite counts * chore(deps): bump @platform-coop-toolkit/pinecone to 1.0.0-alpha.9 * feat: add filled favorite icon * feat: allow removal of favorites from favorites page * chore(docs): add TODO comment * feat: use new format icons * feat: check for cookies * feat: implement many changes from Pinecone * fix: add @wordpress/i18n * feat: add remove all capability * fix: remove extraneous Card initializations * feat: add notifications to favorites page * feat: add notices to single resource page * fix: menu script * fix: use new pagination markup * fix: use new pagination markup * fix: remove redundant roles to prevent duplicate announcements * feat: make notifications sticky * feat: temporary styling, prevent stacked notifications * feat: clean up styles to match platform-coop-toolkit/pinecone#242 * fix: add alert role to notifications
- Loading branch information
Ned Zimmerman
committed
Feb 14, 2020
1 parent
01e461e
commit a7d61ae
Showing
26 changed files
with
647 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Controllers; | ||
|
||
use Sober\Controller\Controller; | ||
|
||
class PageFavorites extends Controller | ||
{ | ||
public function favorites() | ||
{ | ||
return new \WP_Query([ | ||
'post_type' => 'lc_resource', | ||
'post__in' => explode(',', $_COOKIE['favorites']), | ||
'orderby' => 'title', | ||
'posts_per_page' => -1, | ||
'order' => 'asc', | ||
'lang' => '', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
/** | ||
* AJAX hook which can be used to increment or decrement a resource's favorite count. | ||
*/ | ||
function update_favorites() | ||
{ | ||
if (!check_ajax_referer('coop-library-framework-nonce', 'coop_library_nonce')) { | ||
wp_send_json_error('Invalid security token.'); | ||
wp_die(); | ||
} | ||
|
||
$ids = explode(',', $_POST['post_id']); | ||
|
||
foreach ($ids as $id) { | ||
$post_id = absint($id); | ||
$favorites = get_post_meta($post_id, 'lc_resource_favorites', true); | ||
switch ($_POST['operation']) { | ||
case 'increment': | ||
$favorites++; | ||
break; | ||
case 'decrement': | ||
$favorites--; | ||
break; | ||
} | ||
update_post_meta($post_id, 'lc_resource_favorites', $favorites); | ||
} | ||
die(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.