admin_url( 'admin-ajax.php' ) ) ); } /** * * Add message boxes for the CPT "cf72ch_data" * * @method action__cf72ch_add_meta_boxes * */ function action__cf72ch_add_meta_boxes() { add_meta_box( 'cf72ch-data', __( 'From Data', 'accept-2checkout-payments-using-contact-form-7' ), array( $this, 'cf72ch_show_from_data' ), CF72CH_POST_TYPE, 'normal', 'high' ); add_meta_box( 'cf72ch-help', __( 'Do you need help for configuration?', 'accept-2checkout-payments-using-contact-form-7' ), array( $this, 'cf72ch_show_help_data' ), CF72CH_POST_TYPE, 'side', 'high' ); } /** * Action: cf72ch_wpcf7_save_contact_form * * - Save setting fields data. * * @param object $WPCF7_form */ public function action__cf72ch_wpcf7_save_contact_form( $WPCF7_form ) { $wpcf7 = WPCF7_ContactForm::get_current(); if ( !empty( $wpcf7 ) ) { $post_id = $wpcf7->id(); } $form_fields = array( CF72CH_META_PREFIX . 'use_2checkout', CF72CH_META_PREFIX . 'debug', CF72CH_META_PREFIX . 'payment_mode', CF72CH_META_PREFIX . 'merchant_code', CF72CH_META_PREFIX . 'secret_key', CF72CH_META_PREFIX . 'two_checkout_order_name', CF72CH_META_PREFIX . 'amount', CF72CH_META_PREFIX . 'customer_email', CF72CH_META_PREFIX . 'quantity', CF72CH_META_PREFIX . 'currency', CF72CH_META_PREFIX . 'success_returnurl', CF72CH_META_PREFIX . 'cancel_returnurl', CF72CH_META_PREFIX . 'billing_first_name', CF72CH_META_PREFIX . 'billing_last_name', CF72CH_META_PREFIX . 'billing_address', CF72CH_META_PREFIX . 'billing_city', CF72CH_META_PREFIX . 'billing_state', CF72CH_META_PREFIX . 'billing_country', CF72CH_META_PREFIX . 'billing_zipcode', ); /** * Save custom form setting fields * * @var array $form_fields */ $form_fields = apply_filters( CF72CH_PREFIX . 'save_fields', $form_fields ); if(!get_option('_exceed_cf72ch_l')){ add_option('_exceed_cf72ch_l', 'cf72ch10'); } if ( !empty( $form_fields ) ) { foreach ( $form_fields as $key ) { if( isset( $_REQUEST[ $key ] ) ){ $keyval = sanitize_text_field( $_REQUEST[ $key ] ); trim( sanitize_text_field( update_post_meta( $post_id, $key, $keyval ) ) ); }else{ trim( sanitize_text_field( update_post_meta( $post_id, $key, '' ) ) ); } } } } /** * Action: manage_data_posts_custom_column * * @method manage_cf72ch_data_posts_custom_column * * @param string $column * @param int $post_id * * @return string */ function action__manage_cf72ch_data_posts_custom_column( $column, $post_id ) { $data_ct = $this->cf72ch_check_data_ct( sanitize_text_field( $post_id ) ); switch ( $column ) { case 'invoice_no' : if( $data_ct ){ echo 'To unlock more features consider upgrading to PRO'; }else{ echo ( !empty( get_post_meta( $post_id , '_invoice_no', true ) ) ? ( ( !empty( CF72CH()->lib->response_status ) && array_key_exists( get_post_meta( $post_id , '_invoice_no', true ), CF72CH()->lib->response_status) ) ? CF72CH()->lib->response_status[get_post_meta( $post_id , '_invoice_no', true )] : trim( sanitize_text_field( get_post_meta( $post_id , '_invoice_no', true ) ) ) ) : '' ); } break; case 'order_id' : if( $data_ct ){ echo 'To unlock more features consider upgrading to PRO'; }else{ echo ( !empty( get_post_meta( $post_id , '_order_id', true ) ) ? ( ( !empty( CF72CH()->lib->response_status ) && array_key_exists( get_post_meta( $post_id , '_order_id', true ), CF72CH()->lib->response_status) ) ? CF72CH()->lib->response_status[get_post_meta( $post_id , '_order_id', true )] : trim( sanitize_text_field( get_post_meta( $post_id , '_order_id', true ) ) ) ) : '' ); } break; case 'transaction_status' : if( $data_ct ){ echo 'To unlock more features consider upgrading to PRO'; }else{ echo ( !empty( get_post_meta( $post_id , '_transaction_status', true ) ) ? ( ( !empty( CF72CH()->lib->response_status ) && array_key_exists( get_post_meta( $post_id , '_transaction_status', true ), CF72CH()->lib->response_status) ) ? CF72CH()->lib->response_status[get_post_meta( $post_id , '_transaction_status', true )] : trim( sanitize_text_field( get_post_meta( $post_id , '_transaction_status', true ) ) ) ) : '' ); } break; case 'total' : if( $data_ct ){ echo 'To unlock more features consider upgrading to PRO'; }else{ echo ( !empty( get_post_meta( $post_id , '_total', true ) ) ? trim( sanitize_text_field( get_post_meta( $post_id , '_total', true ) ) ) : '' ); } break; } } /** * Action: pre_get_posts * * - Used to perform order by into CPT List. * * @method action__cf72ch_pre_get_posts * * @param object $query WP_Query */ function action__cf72ch_pre_get_posts( $query ) { if ( ! is_admin() || !in_array ( $query->get( 'post_type' ), array( CF72CH_POST_TYPE ) ) ) return; $orderby = $query->get( 'orderby' ); if ( '_total' == $orderby ) { $query->set( 'meta_key', '_total' ); $query->set( 'orderby', 'meta_value_num' ); } } /** * Action: restrict_manage_posts * * - Used to creat filter by form and export functionality. * * @method action__cf72ch_restrict_manage_posts * * @param string $post_type */ function action__cf72ch_restrict_manage_posts( $post_type ) { if ( CF72CH_POST_TYPE != $post_type ) { return; } $posts = get_posts( array( 'post_type' => 'wpcf7_contact_form', 'post_status' => 'publish', 'suppress_filters' => false, 'posts_per_page' => -1, 'meta_key' => 'cf72ch_use_2checkout', 'meta_value' => 1, ) ); if ( empty( $posts ) ) { return; } $selected = ( isset( $_REQUEST['form-id'] ) ? sanitize_text_field( $_REQUEST['form-id'] ) : '' ); echo ''; } /** * Action: parse_query * * - Filter data by form id. * * @method action__cf72ch_parse_query * * @param object $query WP_Query */ function action__cf72ch_parse_query( $query ) { if ( ! is_admin() || !in_array ( $query->get( 'post_type' ), array( CF72CH_POST_TYPE ) ) ) return; if ( is_admin() && isset( $_REQUEST['form-id'] ) && 'all' != $_REQUEST['form-id'] ) { $query->query_vars['meta_value'] = sanitize_text_field( $_REQUEST['form-id'] ); $query->query_vars['meta_compare'] = '='; } } /** * Action: CF72CH_PREFIX /postbox * * - Added metabox for the setting fields in backend. * * @method action__cf72ch_postbox */ function action__cf72ch_postbox() { echo '
' . apply_filters( CF72CH_PREFIX . '/help/postbox', '

' . __( 'Do you need help for configuration?', 'accept-2checkout-payments-using-contact-form-7' ) . '

' . '

' . '
    ' . '
  1. Refer the document.
  2. ' . '
  3. Contact Us
  4. ' . '
' ) . '
'; } /** * Action: review done * * - Review done. * * @method action__cf72ch_review_done */ function action__cf72ch_review_done(){ if( isset( $_POST['value'] ) && $_POST['value'] == 1 ){ add_option( 'cf72ch_review', "1" ); } } /* ######## ## ## ## ## ###### ######## #### ####### ## ## ###### ## ## ## ### ## ## ## ## ## ## ## ### ## ## ## ## ## ## #### ## ## ## ## ## ## #### ## ## ###### ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ## ## ## ## #### ## ## ## ## ## ## #### ## ## ## ## ## ### ## ## ## ## ## ## ## ### ## ## ## ####### ## ## ###### ## #### ####### ## ## ###### */ /** * - Used to display the form data in CPT detail page. * * @method cf72ch_show_from_data * * @param object $post WP_Post */ function cf72ch_show_from_data( $post ) { $fields = CF72CH()->lib->data_fields; $form_id = get_post_meta( $post->ID, '_form_id', true ); $post_type = $post->post_type; $data_ct = $this->cf72ch_check_data_ct( $post->ID ); if( $data_ct ) { echo ''. ''; echo''; echo''; echo '
You are using Free Accept 2Checkout Payments Using Contact Form 7 - no license needed. Enjoy! 🙂‚
To unlock more features consider upgrading to PRO.
'; }else{ echo '' . ''; if ( !empty( $fields ) ) { if ( array_key_exists( '_transaction_response', $fields ) && empty( get_post_meta( $form_id, CF72CH_META_PREFIX . 'debug', true ) ) ) { unset( $fields['_transaction_response'] ); } $attachment = ( !empty( get_post_meta( $post->ID, '_attachment', true ) ) ? unserialize( get_post_meta( $post->ID, '_attachment', true ) ) : '' ); $root_path = get_home_path(); foreach ( $fields as $key => $value ) { if ( !empty( get_post_meta( $post->ID, $key, true ) ) && $key != '_form_data' && $key != '_transaction_response' && $key != '_transaction_status' ) { $val = trim( sanitize_text_field( get_post_meta( $post->ID, $key, true ) ) ); echo '' . '' . '' . ''; } else if( !empty( get_post_meta( $post->ID, $key, true ) ) && $key == '_transaction_status' ){ echo '' . '' . '' . ''; } else if ( !empty( get_post_meta( $post->ID, $key, true ) ) && $key == '_transaction_status' ) { echo '' . '' . '' . ''; } else if ( !empty( get_post_meta( $post->ID, $key, true ) ) && $key == '_form_data' ) { echo '' . '' . ''; } else if ( !empty( get_post_meta( $post->ID, $key, true ) ) && $key == '_transaction_response' ) { echo '' . '' . '' . ''; } } } echo '
' . '' . '' . ( ( '_form_id' == $key && !empty( get_the_title( get_post_meta( $post->ID, $key, true ) ) ) ) ? get_the_title( get_post_meta( $post->ID, $key, true ) ) : trim( sanitize_text_field( get_post_meta( $post->ID, $key, true ) ) ) ) . '
' . '' . '' . ( ( !empty( CF72CH()->lib->response_status ) && array_key_exists( get_post_meta( $post->ID , $key, true ), CF72CH()->lib->response_status ) ) ? CF72CH()->lib->response_status[get_post_meta( $post->ID , $key, true )] : trim( sanitize_text_field( get_post_meta( $post->ID , $key, true ) ) ) ) . '
' . '' . '' . ( ( !empty( CF72CH()->lib->response_status ) && array_key_exists( get_post_meta( $post->ID , $key, true ), CF72CH()->lib->response_status ) ) ? CF72CH()->lib->response_status[get_post_meta( $post->ID , $key, true )] : trim( sanitize_text_field( get_post_meta( $post->ID , $key, true ) ) ) ) . '
' . '' . '' . ''; $data = unserialize( get_post_meta( $post->ID, $key, true ) ); $hide_data = apply_filters( CF72CH_PREFIX . '/hide-display', array( '_wpcf7', '_wpcf7_version', '_wpcf7_locale', '_wpcf7_unit_tag', '_wpcf7_container_post' ) ); foreach ( $hide_data as $key => $value ) { if ( array_key_exists( $value, $data ) ) { unset( $data[$value] ); } } if ( !empty( $data ) ) { foreach ( $data as $key => $value ) { if ( strpos( $key, 'two_checkout-' ) === false ) { echo '' . '' . '' . ''; } } } echo '
' . __( sprintf( '%s', $key ), 'accept-2checkout-payments-using-contact-form-7' ) . '' . ( ( !empty( $attachment ) && array_key_exists( $key, $attachment ) ) ? '' . __( sprintf( '%s', substr($attachment[$key], strrpos($attachment[$key], '/') + 1) ), 'accept-2checkout-payments-using-contact-form-7' ) . '' : __( sprintf( '%s', ( is_array($value) ? implode( ', ', $value ) : $value ) ), 'accept-2checkout-payments-using-contact-form-7' ) ) . '
' . '
' . '' . '' . '' . ( trim( sanitize_text_field( get_post_meta( $post->ID , $key, true ) ) ) ) . '' . '
'; } } /** * - Used to add meta box in CPT detail page. */ function cf72ch_show_help_data() { echo '
' . apply_filters( CF72CH_PREFIX . '/help/'.CF72CH_POST_TYPE.'/postbox', '
    ' . '
  1. Refer the document.
  2. ' . '
  3. Contact Us
  4. ' . '
' ) . '
'; } /** * Check CT */ function cf72ch_check_data_ct( $post_id ){ $data = unserialize( get_post_meta( $post_id, '_form_data', true ) ); if( !empty( get_post_meta( $post_id, '_form_data', true ) ) && isset( $data['_exceed_num_cf72ch'] ) && !empty( $data['_exceed_num_cf72ch'] ) ){ return $data['_exceed_num_cf72ch']; }else{ return ''; } } } add_action( 'plugins_loaded' , function() { CF72CH()->admin->action = new CF72CH_Admin_Action; } ); }