PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.4.2
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.4.2
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / WordPress / ActionsService.php
ActionsService.php
48 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package SureCartAppCore
4 * @author SureCart <support@surecart.com>
5 * @copyright SureCart
6 * @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7 * @link https://surecart.com
8 */
9
10 namespace SureCart\WordPress;
11
12 /**
13 * Main communication channel with the theme.
14 */
15 class ActionsService {
16 /**
17 * Broadcast the php hook.
18 * This sets the a transient so that it is not accidentally broadcasted twice.
19 *
20 * @param string $event Event name.
21 * @param \SureCart\Model $model Model.
22 *
23 * @return void
24 */
25 public function doOnce( $event, $model ) {
26 $action = get_transient( 'surecart_action_' . $event . $model->id, false );
27 if ( false === $action ) {
28 // perform the action.
29 do_action( $event, $model );
30 set_transient( 'surecart_action_' . $event . $model->id, true, MINUTE_IN_SECONDS );
31 }
32 return $this;
33 }
34
35 /**
36 * Clear any previous action.
37 *
38 * @param string $event Event name.
39 * @param \SureCart\Model $model Model.
40 *
41 * @return void
42 */
43 public function clear( $event, $model ) {
44 delete_transient( 'surecart_action_' . $event . $model->id );
45 return $this;
46 }
47 }
48