OrderPK ! fn1 account/unlocked-posts.phpnu [
PK ! Y'Z account/init.phpnu [ 'fa-credit-card', 'title' => pencipw_text_translation( 'penci_paywall_sub' ), 'slug' => get_theme_mod( 'pencipw_text_subscription_slug', 'my-subscription' ), 'label' => 'my_subscription', ); $item['penci_paywall_unl'] = array( 'icon' => 'fa-unlock ', 'title' => pencipw_text_translation( 'penci_paywall_unl' ), 'slug' => get_theme_mod( 'pencipw_text_unlocked_slug', 'unlocked-posts' ), 'label' => 'unlocked_posts', ); $this->endpoint = apply_filters( 'penci_paywall_endpoint', $item ); if ( isset( $this->endpoint ) ) { $endpoint = array_merge( $endpoint, $this->endpoint ); } return $endpoint; } public function add_loggedin_items( $items ) { $custom_items = $this->endpoint; $post_slug = get_theme_mod( 'penci_frontend_submit_account_slug', 'account' ); foreach ( $custom_items as $item ) { $items[ $item['label'] ] = array( 'icon' => $item['icon'], 'link' => esc_attr( home_url( '/' ) . $post_slug . '/' . $item['slug'] ), 'text' => $item['title'], ); } return $items; } /** * Get content template for frontend account page */ public function get_right_content() { global $wp; if ( is_user_logged_in() ) { if ( isset( $wp->query_vars['account'] ) && ! empty( $wp->query_vars['account'] ) ) { $query_vars = explode( '/', $wp->query_vars['account'] ); if ( $query_vars[0] == get_theme_mod( 'pencipw_text_subscription_slug', 'my-subscription' ) ) { $template = PENCI_PAYWALL_PATH . 'account/my-subscription.php'; if ( file_exists( $template ) ) { include $template; } } elseif ( $query_vars[0] == get_theme_mod( 'pencipw_text_unlocked_slug', 'unlocked-posts' ) ) { $template = PENCI_PAYWALL_PATH . 'account/unlocked-posts.php'; if ( file_exists( $template ) ) { include $template; } } } } } } Account_Status::instance();PK ! nL L account/my-subscription.phpnu [ get_payment_method(); } } if ( class_exists( 'WPInv_Subscription' ) ) { $subscription = new \WPInv_Subscription( $subscription_id ); $cancel_subscription_url = $subscription->get_cancel_url(); } if ( $subscribe_status && 'ACTIVE' === $subscribe_status && $current_date <= $expired_date ) { $mystatus = '' . $header_description . '
'; $header_text .= $login; $header_text .= '
>
get_items() as $item ) { $product = wc_get_product( $item['product_id'] ); if ( $product->is_type( 'paywall_subscribe' ) ) { return true; } } } else { if ( ! is_null( WC()->cart ) ) { foreach ( WC()->cart->get_cart() as $cart_item ) { $product = wc_get_product( $cart_item['product_id'] ); if ( $product->is_type( 'paywall_subscribe' ) ) { return true; } } } } return false; } } /** * Check unlock product */ if ( ! function_exists( 'pencipw_is_unlock' ) ) { function pencipw_is_unlock( $order_id = null ) { $order = null; if ( isset( $order_id ) ) { $order = new WC_Order( $order_id ); } elseif ( isset( $_GET['pay_for_order'] ) && isset( $_GET['key'] ) ) { $order_id = wc_get_order_id_by_order_key( wc_clean( wp_unslash( sanitize_text_field( $_GET['key'] ) ) ) ); $order = new WC_Order( $order_id ); } elseif ( is_wc_endpoint_url( 'add-payment-method' ) ) { return false; } if ( isset( $order ) ) { foreach ( $order->get_items() as $item ) { $product = wc_get_product( $item['product_id'] ); if ( $product->is_type( 'paywall_unlock' ) ) { return true; } } } else { if ( ! is_null( WC()->cart ) ) { foreach ( WC()->cart->get_cart() as $cart_item ) { $product = wc_get_product( $cart_item['product_id'] ); if ( $product->is_type( 'paywall_unlock' ) ) { return true; } } } } return false; } } if ( ! function_exists( 'pencipw_timezone_list' ) ) { /** * Gives a list of timezone. * * @since 1.0.0 */ function pencipw_timezone_list() { $structure = array(); // Do manual UTC offsets. $offset_range = array( - 12, - 11.5, - 11, - 10.5, - 10, - 9.5, - 9, - 8.5, - 8, - 7.5, - 7, - 6.5, - 6, - 5.5, - 5, - 4.5, - 4, - 3.5, - 3, - 2.5, - 2, - 1.5, - 1, - 0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14, ); foreach ( $offset_range as $offset ) { $offset_value = $offset; if ( 0 <= $offset ) { $offset_name = '+' . $offset; } else { $offset_name = (string) $offset; } $offset_name = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $offset_name ); $offset_name = 'UTC' . $offset_name; $structure[ esc_attr( $offset_value ) ] = esc_html( $offset_name ); } return $structure; } } if ( ! function_exists( 'pencipw_text_translation_list' ) ) { function pencipw_text_translation_list() { return [ 'unclock_confirm' => __( 'Are you sure want to unlock this post?', 'penci-paywall' ), 'unclock_left' => __( 'Unlock left', 'penci-paywall' ), 'yes' => __( 'Yes', 'penci-paywall' ), 'no' => __( 'No', 'penci-paywall' ), 'cancal_confirm' => __( 'Are you sure want to cancel subscription?', 'penci-paywall' ), 'penci_paywall_sub' => __( 'Subscription', 'penci-paywall' ), 'penci_paywall_unl' => __( 'Unlocked Posts', 'penci-paywall' ), 'subid' => __( 'Subscription ID', 'penci-paywall' ), 'sub_status' => __( 'Subscription Status', 'penci-paywall' ), 'remaining_time' => __( 'Remaining Time', 'penci-paywall' ), 'next_due' => __( 'Next Payment Due', 'penci-paywall' ), 'payment_type' => __( 'Payment Type', 'penci-paywall' ), 'active' => __( 'ACTIVE', 'penci-paywall' ), 'cancel_subscription' => __( 'Cancel Subscription', 'penci-paywall' ), 'no_subscribed' => __( 'You are not subscribed', 'penci-paywall' ), 'subscribed_now' => __( 'Subscribe Now', 'penci-paywall' ), 'quotas_left' => __( 'Quotas Left', 'penci-paywall' ), 'posts_owned' => __( 'Posts Owned', 'penci-paywall' ), 'unlocks' => __( 'unlocks', 'penci-paywall' ), 'posts' => __( 'posts', 'penci-paywall' ), 'posts_collection' => __( 'Unlocked Posts Collection', 'penci-paywall' ), 'noposts' => __( 'No Post Found !', 'penci-paywall' ), ]; } } if ( ! function_exists( 'pencipw_text_translation' ) ) { function pencipw_text_translation( $text ) { $translations = pencipw_text_translation_list(); $option = 'pencipw_text_' . $text; return get_theme_mod( $option ) ? do_shortcode( get_theme_mod( $option ) ) : $translations[ $text ]; } } if ( ! function_exists( 'pencipw_duration_text' ) ) { function pencipw_duration_text( $total, $duration ) { $text = ''; switch ( $duration ) { case 'day': case 'D': $text = __( 'days', 'penci-paywall' ); break; case 'week': case 'W': $text = __( 'weeks', 'penci-paywall' ); break; case 'month': case 'M': $text = __( 'months', 'penci-paywall' ); break; case 'year': case 'Y': $text = __( 'years', 'penci-paywall' ); break; } return $total . ' ' . $text; } }PK ! gc inc/ajax-handle.phpnu [ request ); if ( isset( $_COOKIE['paywall_product'] ) && function_exists( 'wc_get_checkout_url' ) ) { $login_reload = wc_get_checkout_url(); } wp_send_json( array( 'message' => 'success', 'login_reload' => $login_reload, ) ); } public function add_product_ajax() { if ( isset( $_POST['product_id'] ) && isset( $_POST['action'] ) && $_POST['action'] == 'add_paywall_product' ) { $product_id = (int) sanitize_text_field( $_POST['product_id'] ); $product = get_post( $product_id ); try { if ( $product->post_type !== 'product' ) { throw new Exception( esc_html__( 'This is not a product', 'penci-paywall' ) ); } WC()->cart->add_to_cart( $product_id ); $redirect = wc_get_checkout_url(); wp_send_json( array( 'message' => esc_html__( 'added', 'penci-paywall' ), 'redirect' => $redirect, ) ); } catch ( Exception $e ) { throw new Exception( esc_html__( 'Error adding product', 'penci-paywall' ) ); } } die(); } /** * Ajax for Unlock Post */ public function unlock_post_ajax() { if ( is_user_logged_in() && isset( $_POST['unlock_post_id'] ) ) { if ( $_POST['unlock_post_id'] == 1 && $_POST['action'] == 'paywall_handler' ) { $unlock_remaining = get_user_option( 'pencipw_unlock_remaining', get_current_user_id() ) ? get_user_option( 'pencipw_unlock_remaining', get_current_user_id() ) : 0; $unlocked_posts = get_user_option( 'pencipw_unlocked_post_list', get_current_user_id() ) ? get_user_option( 'pencipw_unlocked_post_list', get_current_user_id() ) : array(); $post_id = (int) sanitize_text_field( $_POST['post_id'] ); if ( $unlock_remaining > 0 && ! in_array( (int) $post_id, $unlocked_posts ) ) { $unlocked_posts[] = $post_id; $unlock_remaining = $unlock_remaining - 1; update_user_option( get_current_user_id(), 'pencipw_unlocked_post_list', $unlocked_posts ); update_user_option( get_current_user_id(), 'pencipw_unlock_remaining', $unlock_remaining ); } } } wp_send_json( array( 'message' => esc_html__( 'paywall ajax sent', 'penci-paywall' ), ) ); die(); } public function cancel_subs_ajax() { if ( is_user_logged_in() && isset( $_POST['cancel_subscription'] ) ) { if ( $_POST['cancel_subscription'] == 'yes' && $_POST['action'] == 'cancel_subs_handler' ) { $paypal_subs_id = get_user_option( 'pencipw_paypal_subs_id', get_current_user_id() ); $stripe_subs_id = get_user_option( 'pencipw_stripe_subs_id', get_current_user_id() ); if ( $paypal_subs_id != '' ) { $credentials = new \PenciPW_Paypal(); $subscribe_cancel = new Paypal_Api( 'cancel', $credentials->get_api_credential() ); if ( $subscribe_cancel->get_response_message() == '204' ) { update_user_option( get_current_user_id(), 'pencipw_subscribe_status', false ); update_user_option( get_current_user_id(), 'pencipw_expired_date', false ); } } if ( $stripe_subs_id != '' ) { $credentials = new \PenciPW_Stripe(); $subscribe_cancel = new Stripe_Api( 'cancel', $credentials->get_api_credential() ); $response = $subscribe_cancel->get_response_message(); if ( isset( $response['status'] ) ) { if ( $response['status'] == 'canceled' || $response['status'] == 'error' ) { update_user_option( get_current_user_id(), 'pencipw_subscribe_status', false ); update_user_option( get_current_user_id(), 'pencipw_expired_date', false ); } } } /** WCS Integration */ if ( function_exists( 'wcs_get_subscription' ) ) { $subscription_id = get_user_option( 'pencipw_subscribe_id', get_current_user_id() ); if ( ! empty( $subscription_id ) || ! $subscription_id ) { $subscription = wcs_get_subscription( $subscription_id ); if ( is_object( $subscription ) ) { $subscription->set_payment_method(); if ( $subscription->can_be_updated_to( 'cancelled' ) ) { $subscription->update_status( 'cancelled' ); update_user_option( get_current_user_id(), 'pencipw_subscribe_status', false ); update_user_option( get_current_user_id(), 'pencipw_expired_date', false ); update_user_option( get_current_user_id(), 'pencipw_subscribe_id', false ); } } } } } } wp_send_json( array( 'message' => esc_html__( 'cancel subscription', 'penci-paywall' ), ) ); die(); } public function default_source() { if ( is_user_logged_in() && isset( $_POST['source_id'] ) ) { $customer_id = get_user_option( 'pencipw_stripe_customer_id', get_current_user_id() ); $source_id = sanitize_text_field( $_POST['source_id'] ); if ( $customer_id != '' ) { $credentials = new \PenciPW_Stripe(); $request = new Stripe_Api( 'update_default_source', $credentials->get_api_credential(), null, null, array( $customer_id, array( 'default_source' => $source_id ) ) ); } } wp_send_json( array( 'message' => esc_html__( 'default source', 'penci-paywall' ), ) ); die(); } } PaywallAjaxHandle::instance();PK ! 46! 6! inc/init.phpnu [ setup_init(); $this->setup_hook(); $this->register_gateway(); PaywallAjaxHandle::instance(); add_action( 'init', array( $this, 'update_user_status' ) ); add_action( 'plugins_loaded', array( $this, 'load_woocommerce_class' ) ); add_action( 'wp_enqueue_scripts', [ $this, 'frontend_assets' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'admin_assets' ] ); add_action( 'elementor/widgets/register', [ $this, 'elementor_widget' ] ); add_action( 'wp_footer', [ $this, 'footer_login_form' ] ); add_action( 'soledad_theme/custom_css', [ $this, 'custom_css' ] ); add_action( 'admin_notices', [ $this, 'paywall_notice' ] ); add_action( 'init', [ $this, 'remove_ads' ] ); add_action( 'init', [ $this, 'hide_ads_unit' ] ); } public function remove_ads() { $subscribe_status = get_user_option( 'pencipw_subscribe_status', get_current_user_id() ); $expired = get_user_option( 'pencipw_expired_date', get_current_user_id() ) ? get_user_option( 'pencipw_expired_date', get_current_user_id() ) : Date( 'F d, Y' ); $current_date = new DateTime(); $expired_date = new DateTime( $expired ); $hide_ads = get_theme_mod( 'pencipw_subscribe_ads' ); if ( $hide_ads && $subscribe_status && 'ACTIVE' === $subscribe_status && $current_date <= $expired_date ) { add_filter( 'penci_show_ads', '__return_false' ); } } public function hide_ads_unit() { $show_ads = apply_filters( 'penci_show_ads', true ); if ( ! $show_ads ) { $options = [ 'penci_header_3_adsense', 'penci_infeedads_home_code', 'penci_home_adsense_below_slider', 'penci_arcf_adbelow', 'penci_archive_ad_above', 'penci_archive_ad_below', 'penci_infeedads_archi_code', 'penci_ads_inside_content_html', 'penci_post_adsense_single10', 'penci_post_adsense_one', 'penci_post_adsense_two', 'penci_loadnp_ads', 'penci_floatads_enable', 'penci_footer_adsense' ]; foreach ( $options as $option ) { add_filter( 'theme_mod_' . $option, '__return_false' ); } } } public function paywall_notice() { if ( ! class_exists( 'WooCommerce' ) && ! function_exists( 'getpaid' ) ): ?>Penci Paywall required GetPaid or WooCommerce plugin to add the payment gateway. Please install these plugins here.', 'penci-paywall' ); ?>