Skip to content

Commit

Permalink
newly renamed functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kendysond committed Sep 17, 2016
1 parent 8f9cccf commit 82a1386
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 90 deletions.
Binary file modified .DS_Store
Binary file not shown.
156 changes: 66 additions & 90 deletions admin/class-paystack-forms-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@ public function __construct( $plugin_name, $version ) {

$this->plugin_name = $plugin_name;
$this->version = $version;
add_action('admin_menu' , 'add_settings_page');
add_action( 'admin_init', 'register_paystack_setting_page' );
add_action('admin_menu' , 'kkd_pff_paystack_add_settings_page');
add_action( 'admin_init', 'kkd_pff_paystack_register_setting_page' );

function add_settings_page() {
add_submenu_page('edit.php?post_type=paystack_form', 'Api Keys Settings', 'Api Keys Settings', 'edit_posts', basename(__FILE__), 'paystack_setting_page');
function kkd_pff_paystack_add_settings_page() {
add_submenu_page('edit.php?post_type=paystack_form', 'Api Keys Settings', 'Api Keys Settings', 'edit_posts', basename(__FILE__), 'kkd_pff_paystack_setting_page');
}
function register_paystack_setting_page() {
register_setting( 'paystack-form-settings-group', 'mode' );
register_setting( 'paystack-form-settings-group', 'tsk' );
register_setting( 'paystack-form-settings-group', 'tpk' );
register_setting( 'paystack-form-settings-group', 'lsk' );
register_setting( 'paystack-form-settings-group', 'lpk' );
function kkd_pff_paystack_register_setting_page() {
register_setting( 'kkd-pff-paystack-settings-group', 'mode' );
register_setting( 'kkd-pff-paystack-settings-group', 'tsk' );
register_setting( 'kkd-pff-paystack-settings-group', 'tpk' );
register_setting( 'kkd-pff-paystack-settings-group', 'lsk' );
register_setting( 'kkd-pff-paystack-settings-group', 'lpk' );
}
function txncheck($name,$txncharge){
function kkd_pff_paystack_txncheck($name,$txncharge){
if ($name == $txncharge) {
$result = "selected";
}else{
$result = "";
}
return $result;
}
function paystack_setting_page() {
function kkd_pff_paystack_setting_page() {
?>
<h1>Paystack Forms API KEYS Settings!</h1>
<form method="post" action="options.php">
<?php settings_fields( 'paystack-form-settings-group' ); do_settings_sections( 'paystack-form-settings-group' ); ?>
<?php settings_fields( 'kkd-pff-paystack-settings-group' ); do_settings_sections( 'kkd-pff-paystack-settings-group' ); ?>
<table class="form-table paystack_setting_page">
<tr valign="top">
<th scope="row">Mode</th>

<td>
<select class="form-control" name="mode" id="parent_id">
<option value="live" <?php echo txncheck('live',esc_attr( get_option('mode') )) ?>>Live Mode</option>
<option value="test" <?php echo txncheck('test',esc_attr( get_option('mode') )) ?>>Test Mode</option>
<option value="live" <?php echo kkd_pff_paystack_txncheck('live',esc_attr( get_option('mode') )) ?>>Live Mode</option>
<option value="test" <?php echo kkd_pff_paystack_txncheck('test',esc_attr( get_option('mode') )) ?>>Test Mode</option>
</select>
</tr>
<tr valign="top">
Expand Down Expand Up @@ -71,8 +71,8 @@ function paystack_setting_page() {
</form>
<?php
}
add_action( 'init', 'register_cpt_paystack_form' );
function register_cpt_paystack_form() {
add_action( 'init', 'register_kkd_pff_paystack' );
function register_kkd_pff_paystack() {

$labels = array(
'name' => _x( 'Paystack Forms', 'paystack_form' ),
Expand Down Expand Up @@ -111,9 +111,9 @@ function register_cpt_paystack_form() {
);
register_post_type( 'paystack_form', $args );
}
add_filter('user_can_richedit', 'disable_wyswyg_for_custom_post_type');
add_filter('user_can_richedit', 'kkd_pff_paystack_disable_wyswyg');

function pform_add_action_button($actions, $post){
function kkd_pff_paystack_add_view_payments($actions, $post){

if(get_post_type() === 'paystack_form'){
unset($actions['view']);
Expand All @@ -128,30 +128,30 @@ function pform_add_action_button($actions, $post){
}
return $actions;
}
add_filter( 'page_row_actions', 'pform_add_action_button', 10, 2 );
add_filter( 'page_row_actions', 'kkd_pff_paystack_add_view_payments', 10, 2 );


function wpa_47010( $qtInit ) {
function kkd_pff_paystack_remove_fullscreen( $qtInit ) {
$qtInit['buttons'] = 'fullscreen';
return $qtInit;
}
function disable_wyswyg_for_custom_post_type( $default ){
function kkd_pff_paystack_disable_wyswyg( $default ){
global $post_type, $_wp_theme_features;;


if ($post_type == 'paystack_form') {
echo "<style>#edit-slug-box,#message p > a{display:none;}</style>";
add_action("admin_print_footer_scripts", "kkd_pff_paystack_shortcode_button_script");
add_filter( 'user_can_richedit' , '__return_false', 50 );
add_action( 'wp_dashboard_setup', 'remove_dashboard_widgets' );
add_action( 'wp_dashboard_setup', 'kkd_pff_paystack_remove_dashboard_widgets' );
remove_action( 'media_buttons', 'media_buttons' );
remove_meta_box( 'postimagediv','post','side' );
add_filter('quicktags_settings', 'wpa_47010');
add_filter('quicktags_settings', 'kkd_pff_paystack_remove_fullscreen');
}

return $default;
}
function remove_dashboard_widgets() {
function kkd_pff_paystack_remove_dashboard_widgets() {
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); // Right Now
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); // Recent Comments
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' ); // Incoming Links
Expand All @@ -162,9 +162,9 @@ function remove_dashboard_widgets() {
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' ); // Other WordPress News
// use 'dashboard-network' as the second parameter to remove widgets from a network dashboard.
}
add_filter( 'manage_edit-paystack_form_columns', 'my_edit_paystack_form_columns' ) ;
add_filter( 'manage_edit-paystack_form_columns', 'kkd_pff_paystack_edit_dashboard_header_columns' ) ;

function my_edit_paystack_form_columns( $columns ) {
function kkd_pff_paystack_edit_dashboard_header_columns( $columns ) {

$columns = array(
'cb' => '<input type="checkbox" />',
Expand All @@ -176,16 +176,16 @@ function my_edit_paystack_form_columns( $columns ) {

return $columns;
}
add_action( 'manage_paystack_form_posts_custom_column', 'my_paystack_form_columns', 10, 2 );
add_action( 'manage_paystack_form_posts_custom_column', 'kkd_pff_paystack_dashboard_table_data', 10, 2 );

function my_paystack_form_columns( $column, $post_id ) {
function kkd_pff_paystack_dashboard_table_data( $column, $post_id ) {
global $post,$wpdb;
$table = $wpdb->prefix . 'paystack_forms_payments';

switch( $column ) {
case 'shortcode' :
echo '<span class="shortcode">
<input type="text" class="large-text code" value="[paystack_form id=&quot;'.$post_id.'&quot;]"
<input type="text" class="large-text code" value="[pff-paystack id=&quot;'.$post_id.'&quot;]"
readonly="readonly" onfocus="this.select();"></span>';

break;
Expand All @@ -200,9 +200,9 @@ function my_paystack_form_columns( $column, $post_id ) {
break;
}
}
add_filter( 'default_content', 'my_editor_content', 10, 2 );
add_filter( 'default_content', 'kkd_pff_paystack_editor_content', 10, 2 );

function my_editor_content( $content, $post ) {
function kkd_pff_paystack_editor_content( $content, $post ) {

switch( $post->post_type ) {
case 'paystack_form':
Expand All @@ -216,25 +216,25 @@ function my_editor_content( $content, $post ) {
return $content;
}
/////
function help_metabox( $post ) {
function kkd_pff_paystack_editor_help_metabox( $post ) {

do_meta_boxes( null, 'custom-metabox-holder', $post );
}
add_action( 'edit_form_after_title', 'help_metabox' );
function add_help_metabox() {
add_action( 'edit_form_after_title', 'kkd_pff_paystack_editor_help_metabox' );
function kkd_pff_paystack_editor_add_help_metabox() {

add_meta_box(
'awesome_metabox_id',
'Help Section',
'help_metabox_details',
'kkd_pff_paystack_editor_help_metabox_details',
'paystack_form',
'custom-metabox-holder' //Look what we have here, a new context
);

}
add_action( 'add_meta_boxes', 'add_help_metabox' );
add_action( 'add_meta_boxes', 'kkd_pff_paystack_editor_add_help_metabox' );

function help_metabox_details( $post ) {
function kkd_pff_paystack_editor_help_metabox_details( $post ) {
echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value="' .
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';

Expand All @@ -252,17 +252,17 @@ function help_metabox_details( $post ) {
<?php
}

add_action( 'add_meta_boxes', 'add_extra_metaboxes' );
function add_extra_metaboxes() {
add_action( 'add_meta_boxes', 'kkd_pff_paystack_editor_add_extra_metaboxes' );
function kkd_pff_paystack_editor_add_extra_metaboxes() {

add_meta_box('wpt_form_data', 'Extra Form Description', 'wpt_form_data', 'paystack_form', 'normal', 'default');
add_meta_box('wpt_recur_data', 'Recurring Payment', 'wpt_recur_data', 'paystack_form', 'side', 'default');
add_meta_box('wpt_email_data', 'Email Receipt Settings', 'wpt_email_data', 'paystack_form', 'normal', 'default');
add_meta_box('kkd_pff_paystack_editor_add_form_data', 'Extra Form Description', 'kkd_pff_paystack_editor_add_form_data', 'paystack_form', 'normal', 'default');
add_meta_box('kkd_pff_paystack_editor_add_recur_data', 'Recurring Payment', 'kkd_pff_paystack_editor_add_recur_data', 'paystack_form', 'side', 'default');
add_meta_box('kkd_pff_paystack_editor_add_email_data', 'Email Receipt Settings', 'kkd_pff_paystack_editor_add_email_data', 'paystack_form', 'normal', 'default');

}


function wpt_form_data() {
function kkd_pff_paystack_editor_add_form_data() {
global $post;

// Noncename needed to verify where the data originated
Expand Down Expand Up @@ -292,22 +292,22 @@ function wpt_form_data() {
echo '<p>Pay button Description:</p>';
echo '<input type="text" name="_paybtn" value="' . $paybtn . '" class="widefat" />';
echo '<p>Transaction Charges:</p>';
echo '<select class="form-control" name="_txncharge" id="parent_id" style="width:100%;">
<option value="merchant"'.txncheck('merchant',$txncharge).'>Merchant Pays(Include in fee)</option>
<option value="customer" '.txncheck('customer',$txncharge).'>Client Pays(Extra Fee added)</option>
</select>';
// echo '<select class="form-control" name="_txncharge" id="parent_id" style="width:100%;">
// <option value="merchant"'.kkd_pff_paystack_txncheck('merchant',$txncharge).'>Merchant Pays(Include in fee)</option>
// <option value="customer" '.kkd_pff_paystack_txncheck('customer',$txncharge).'>Client Pays(Extra Fee added)</option>
// </select>';
echo '<p>User logged In:</p>';
echo '<select class="form-control" name="_loggedin" id="parent_id" style="width:100%;">
<option value="no" '.txncheck('no',$loggedin).'>User must not be logged in</option>
<option value="yes"'.txncheck('yes',$loggedin).'>User must be logged In</option>
<option value="no" '.kkd_pff_paystack_txncheck('no',$loggedin).'>User must not be logged in</option>
<option value="yes"'.kkd_pff_paystack_txncheck('yes',$loggedin).'>User must be logged In</option>
</select>';
echo '<p>Success Message after Payment</p>';
echo '<textarea rows="3" name="_successmsg" class="widefat" >'.$successmsg.'</textarea>';
echo '<p>File Upload Limit(MB):</p>';
echo '<input ttype="number" name="_filelimit" value="' . $filelimit . '" class="widefat pf-number" />';

}
function wpt_email_data() {
function kkd_pff_paystack_editor_add_email_data() {
global $post;

// Noncename needed to verify where the data originated
Expand All @@ -327,8 +327,8 @@ function wpt_email_data() {
// Echo out the field
echo '<p>Send Email Receipt:</p>';
echo '<select class="form-control" name="_sendreceipt" id="parent_id" style="width:100%;">
<option value="no" '.txncheck('no',$sendreceipt).'>Don\'t send</option>
<option value="yes" '.txncheck('yes',$sendreceipt).'>Send</option>
<option value="no" '.kkd_pff_paystack_txncheck('no',$sendreceipt).'>Don\'t send</option>
<option value="yes" '.kkd_pff_paystack_txncheck('yes',$sendreceipt).'>Send</option>
</select>';
echo '<p>Email Subject:</p>';
echo '<input type="text" name="_subject" value="' . $subject . '" class="widefat" />';
Expand All @@ -338,7 +338,7 @@ function wpt_email_data() {
echo '<textarea rows="6" name="_message" class="widefat" >'.$message.'</textarea>';

}
function wpt_recur_data() {
function kkd_pff_paystack_editor_add_recur_data() {
global $post;

// Noncename needed to verify where the data originated
Expand All @@ -354,16 +354,16 @@ function wpt_recur_data() {
// Echo out the field
echo '<p>Reccuring Payment:</p>';
echo '<select class="form-control" name="_recur" style="width:100%;">
<option value="no" '.txncheck('no',$recur).'>None</option>
<option value="optional" '.txncheck('optional',$recur).'>Optional Recurring</option>
<option value="plan" '.txncheck('plan',$recur).'>Paystack Plan</option>
<option value="no" '.kkd_pff_paystack_txncheck('no',$recur).'>None</option>
<option value="optional" '.kkd_pff_paystack_txncheck('optional',$recur).'>Optional Recurring</option>
<option value="plan" '.kkd_pff_paystack_txncheck('plan',$recur).'>Paystack Plan</option>
</select>';
echo '<p>Paystack Recur Plan code:</p>';
echo '<input type="text" name="_recurplan" value="' . $recurplan . '" class="widefat" />
<small>Plan amount must match amount on extra form description.</small>';

}
function wpt_form_data_meta($post_id, $post) {
function kkd_pff_paystack_save_data($post_id, $post) {

if ( !wp_verify_nonce( @$_POST['eventmeta_noncename'], plugin_basename(__FILE__) )) {
return $post->ID;
Expand Down Expand Up @@ -404,7 +404,7 @@ function wpt_form_data_meta($post_id, $post) {
}

}
add_action('save_post', 'wpt_form_data_meta', 1, 2);
add_action('save_post', 'kkd_pff_paystack_save_data', 1, 2);



Expand All @@ -413,47 +413,23 @@ function wpt_form_data_meta($post_id, $post) {

public function enqueue_styles() {

/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Paystack_Forms_Loader as all of the hooks are defined
* in that particular class.
*
* The Paystack_Forms_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/

wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/paystack-forms-admin.css', array(), $this->version, 'all' );

}
public function enqueue_scripts() {

/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Paystack_Forms_Loader as all of the hooks are defined
* in that particular class.
*
* The Paystack_Forms_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/

wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/paystack-forms-admin.js', array( 'jquery' ), $this->version, false );

}

}

add_action( 'admin_menu', 'register_newpage' );
function register_newpage(){
add_menu_page('paystack', 'paystack', 'administrator','submissions', 'payment_submissions');
add_action( 'admin_menu', 'kkd_pff_paystack_register_newpage' );
function kkd_pff_paystack_register_newpage(){
add_menu_page('paystack', 'paystack', 'administrator','submissions', 'kkd_pff_paystack_payment_submissions');
remove_menu_page('submissions');
}
function payment_submissions(){
function kkd_pff_paystack_payment_submissions(){
$id = $_GET['form'];
$obj = get_post($id);
if ($obj->post_type == 'paystack_form') {
Expand All @@ -464,7 +440,7 @@ function payment_submissions(){
$txncharge = get_post_meta($id,'_txncharge',true);

echo "<h1>".$obj->post_title." Payments</h1>";
$exampleListTable = new Payments_List_Table();
$exampleListTable = new Kkd_Pff_Paystack_Payments_List_Table();
$exampleListTable->prepare_items();
?>
<div class="wrap">
Expand All @@ -475,7 +451,7 @@ function payment_submissions(){

}
}
class Paystack_Wp_List_Table{
class Kkd_Pff_Paystack_Wp_List_Table{
public function __construct(){
add_action( 'admin_menu', array($this, 'add_menu_example_list_table_page' ));
}
Expand Down Expand Up @@ -522,7 +498,7 @@ function format_data($data){
return $text;
}

class Payments_List_Table extends WP_List_Table{
class Kkd_Pff_Paystack_Payments_List_Table extends WP_List_Table{
public function prepare_items(){
$post_id = $_GET['form'];
$currency = get_post_meta($post_id,'_currency',true);
Expand Down

0 comments on commit 82a1386

Please sign in to comment.