芝麻web文件管理V1.00
编辑当前文件:/home/ephorei/www/wp-content/plugins/suretriggers/functions.php
ID; } add_action( 'in_admin_header', function () { if ( isset( $_GET['page'] ) && 'suretriggers' === sanitize_text_field( $_GET['page'] ) ) { // phpcs:ignore remove_all_actions( 'admin_notices' ); remove_all_actions( 'all_admin_notices' ); } }, 999 ); add_action( 'wp_login', 'suretrigger_capture_login_time', 10, 2 ); /** * Login time. * * @param string $user_login user login. * @param object $user user. * @return void */ function suretrigger_capture_login_time( $user_login, $user ) { update_user_meta( $user->ID, 'st_last_login', time() ); } /** * SureTrigger Trigger Button shortcode. * * @param array $atts Attributes. * @param null $content Content. * @return string|bool */ function suretrigger_button( $atts, $content = null ) { $atts = shortcode_atts( [ 'id' => 0, 'button_label' => __( 'Click here', 'suretriggers' ), 'user_redirect_url' => '', 'visitor_redirect_url' => '', 'button_class' => 'suretrigger_button', 'button_id' => 'suretrigger_button', 'click_loading_label' => __( 'Clicking...', 'suretriggers' ), 'after_clicked_label' => __( 'Clicked!!', 'suretriggers' ), 'click_once' => 'true', 'cookie_duration' => '15', ], $atts, 'trigger_button' ); ob_start(); $user_id = get_current_user_id(); ?>
ID ) && isset( $post->post_title ) ) { ?>
sanitize_text_field( $_POST['st_button_post_id'] ), 'parent_post_title' => sanitize_text_field( $_POST['st_button_post_title'] ), ]; } else { $post_data = []; } do_action( 'st_trigger_button_action', $st_trigger_id, $user_id, sanitize_text_field( $_POST['st_cookie_duration'] ), $_POST['st_click'], $post_data ); } if ( isset( $_POST['st_login_url'] ) && ! empty( $_POST['st_login_url'] ) ) { wp_send_json_success( esc_url( $_POST['st_login_url'] ) ); } } } else { if ( isset( $_POST['st_non_login_url'] ) && ! empty( $_POST['st_non_login_url'] ) ) { wp_send_json_success( esc_url( $_POST['st_non_login_url'] ) ); } else { wp_send_json_success( wp_login_url() ); } } // Trigger the custom hook after ajax response. do_action( 'st_trigger_button_after_click_hook' ); wp_die(); } add_action( 'wp_ajax_handle_trigger_button_click', 'suretrigger_trigger_button_action' ); add_action( 'wp_ajax_nopriv_handle_trigger_button_click', 'suretrigger_trigger_button_action' ); /** * SureTrigger Trigger Button set cookie. * * @param int $st_trigger_id Trigger ID. * @param int $user_id User ID. * @param int $cookie_duration Cookie Duration. * * @return void */ function st_trigger_button_set_cookie( $st_trigger_id, $user_id, $cookie_duration ) { // Set the cookie. $cookie_name = 'st_trigger_button_clicked_' . $st_trigger_id; $cookie_value = 'yes_' . $user_id; if ( isset( $cookie_duration ) ) { $expiration = time() + 60 * 60 * 24 * intval( $cookie_duration ); // Set the expiration time as per user requested. } else { $expiration = time() + 60 * 60 * 24 * 15; } if ( ! defined( 'COOKIEPATH' ) ) { define( 'COOKIEPATH', '/' ); } if ( ! defined( 'COOKIE_DOMAIN' ) ) { define( 'COOKIE_DOMAIN', false ); } setcookie( $cookie_name, $cookie_value, $expiration, COOKIEPATH, COOKIE_DOMAIN ); } add_action( 'st_trigger_button_set_cookie', 'st_trigger_button_set_cookie', 10, 3 );