File: /var/www/concertium.com/public_html/wp-content/themes/dt-the7/functions.php
<?php
/**
* The7 theme.
*
* @package The7
* @since 1.0.0
*/
// File Security Check
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Set the content width based on the theme's design and stylesheet.
* @since 1.0.0
*/
if ( ! isset( $content_width ) ) {
$content_width = 1200; /* pixels */
}
/**
* Initialize theme.
* @since 1.0.0
*/
require( trailingslashit( get_template_directory() ) . 'inc/init.php' );
add_action( 'wp_footer', 'redirect_cf7' );
function redirect_cf7() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '7' == event.detail.contactFormId ) { // Sends sumissions on form 947 to the first thank you page
location = 'https://concertium.com/thank-you/';
}
else if ( '2368' == event.detail.contactFormId ) { // Sends submissions on all unaccounted for forms to the third thank you page
ga('send', 'event', { eventCategory: 'Newsletter', eventAction: 'Submit', eventLabel: 'signup', eventValue: 1});
}
}, false );
</script>
<?php
}
## Custom Post type
add_action( 'init', 'concertum_custom_init' );
function concertum_custom_init() {
$labels = array(
'name' => _x( 'Scoring System', 'post type general name', 'your-plugin-textdomain' ),
'singular_name' => _x( 'Scoring System', 'post type singular name', 'your-plugin-textdomain' ),
'menu_name' => _x( 'Scoring System', 'admin menu', 'your-plugin-textdomain' ),
'name_admin_bar' => _x( 'Scoring System', 'add new on admin bar', 'your-plugin-textdomain' ),
'add_new' => _x( 'Add New', 'design idea', 'your-plugin-textdomain' ),
'add_new_item' => __( 'Add New', 'your-plugin-textdomain' ),
'new_item' => __( 'New Question Answer', 'your-plugin-textdomain' ),
'edit_item' => __( 'Edit Question Answer', 'your-plugin-textdomain' ),
'view_item' => __( 'View Question Answer', 'your-plugin-textdomain' ),
'all_items' => __( 'All Question Answer', 'your-plugin-textdomain' ),
'search_items' => __( 'Search Question Answer', 'your-plugin-textdomain' ),
'parent_item_colon' => __( 'Parent Question Answer:', 'your-plugin-textdomain' ),
'not_found' => __( 'No Questions And Answers found.', 'your-plugin-textdomain' ),
'not_found_in_trash' => __( 'No Questions And Answers found in Trash.', 'your-plugin-textdomain' )
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.', 'your-plugin-textdomain' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'scroing_system' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title')
);
register_post_type( 'scroing_system', $args );
}
// create custom taxonomy for the post type "scroing_system"
add_action( 'init', 'create_concertum_taxonomies' );
function create_concertum_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Category', 'taxonomy general name' ),
'singular_name' => _x( 'Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Category' ),
'all_items' => __( 'All Category' ),
'parent_item' => __( 'Parent Category' ),
'parent_item_colon' => __( 'Parent Category:' ),
'edit_item' => __( 'Edit Category' ),
'update_item' => __( 'Update Category' ),
'add_new_item' => __( 'Add New Category' ),
'new_item_name' => __( 'New Category Name' ),
'menu_name' => __( 'Scoring Category' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'scoring-category' ),
);
register_taxonomy( 'scoring-category', array( 'scroing_system' ), $args );
}
add_action('init', 'start_session', 1);
function start_session() {
if(!session_id()) {
session_start();
}
}
add_action('wp_logout', 'end_session');
add_action('wp_login', 'end_session');
add_action('end_session_action', 'end_session');
function end_session() {
session_destroy ();
}
add_shortcode('dt-scoring-system', 'fun_scoring_system');
function fun_scoring_system()
{
ob_start();
unset($_SESSION['all_submitted_question_answer']);
unset($_SESSION['all_submitted_category_comments']);
unset($_SESSION['contact_details_id']);
include 'dt-scroing_system.php';
$all_content = ob_get_contents();
ob_clean();
return $all_content;
}
add_action("wp_ajax_save_question_answer_temp", "save_question_answer_temp");
add_action("wp_ajax_nopriv_save_question_answer_temp", "save_question_answer_temp");
function save_question_answer_temp()
{
//print_r($_SESSION);
$answerValue = $_REQUEST['answerValue'];
$answerMarks = $_REQUEST['answerMarks'];
$questionType = $_REQUEST['questionType'];
$questionId = $_REQUEST['questionId'];
$categoryEnd = $_REQUEST['categoryEnd'];
$total_score = 0;
$thumbs_up = 0;
$total_max_marks = 0;
$total_answered_question = 0;
$all_questions_answer = get_posts(array(
'post_type' => 'scroing_system',
'numberposts' => -1
));
$total_question_answer = count($all_questions_answer);
global $wpdb;
if (isset($_SESSION['all_submitted_question_answer']))
{
$all_submitted_question_answer = $_SESSION['all_submitted_question_answer'];
if(!empty($all_submitted_question_answer))
{
if (array_key_exists($questionType,$all_submitted_question_answer))
{
$answer_question_details = array();
$answer_details = array();
$answer_details['answerValue'] = $answerValue;
$answer_details['answerMarks'] = $answerMarks;
$answer_question_details[$questionId] = $answer_details;
if (array_key_exists($questionId,$all_submitted_question_answer[$questionType]))
{
unset($all_submitted_question_answer[$questionType][$questionId]);
}
$all_submitted_question_answer[$questionType][$questionId]= $answer_details;
unset($answer_question_details);
unset($answer_details);
}
else
{
$answer_details = array();
$answer_details['answerValue'] = $answerValue;
$answer_details['answerMarks'] = $answerMarks;
$all_submitted_question_answer[$questionType][$questionId] = $answer_details;
unset($answer_details);
}
}
else
{
$answer_details = array();
$answer_details['answerValue'] = $answerValue;
$answer_details['answerMarks'] = $answerMarks;
$all_submitted_question_answer[$questionType][$questionId] = $answer_details;
unset($answer_details);
}
}
else
{
$all_submitted_question_answer = array();
$answer_details = array();
$answer_details['answerValue'] = $answerValue;
$answer_details['answerMarks'] = $answerMarks;
$all_submitted_question_answer[$questionType][$questionId] = $answer_details;
unset($answer_details);
}
//print_r($all_submitted_question_answer);
$_SESSION['all_submitted_question_answer'] = $all_submitted_question_answer;
if($categoryEnd == 1)
{
if(!empty($all_submitted_question_answer[$questionType]))
{
$total_score = 0;
foreach($all_submitted_question_answer[$questionType] as $questiontypeval)
{
$total_score = $total_score + $questiontypeval['answerMarks'];
}
}
$all_questions = get_posts(array(
'post_type' => 'scroing_system',
'numberposts' => -1,
'tax_query' => array(
array(
'taxonomy' => 'scoring-category',
'field' => 'term_id',
'terms' => $questionType,
)
)
));
if(!empty($all_questions))
{
$total_max_marks = ((count($all_questions))*100);
}
else
{
$total_max_marks = 0;
}
if($total_score >0 && $total_max_marks >0)
{
$total_percentage = (($total_score / $total_max_marks)*100);
if($total_percentage >= 75)
{
$thumbs_up = 1;
}
else
{
$thumbs_up = 0;
}
}
else
{
$thumbs_up = 0;
}
}
if (isset($_SESSION['contact_details_id']) || $_SESSION['contact_details_id'] != '')
{
$contact_detailsID = $_SESSION['contact_details_id'];
$all_answered_questions = $wpdb->get_results( "SELECT count(i_id) as total FROM `dt_scoring_details` WHERE i_reviewer_id = ".$contact_detailsID."" );
$total_saved_answered_question = $all_answered_questions[0]->total;
$total_submitted_question_cat = count($all_submitted_question_answer[$questionType]);
$total_answered_question = $total_saved_answered_question + $total_submitted_question_cat;
}
else
{
if(!empty($all_submitted_question_answer))
{
$total_answered_question = 0;
foreach($all_submitted_question_answer as $questiontypeval)
{
$total_answered_question = $total_answered_question + count($questiontypeval);
}
}
$contact_detailsID = 99;
}
if($total_answered_question > 0)
{
$answered_percentage = (($total_answered_question / $total_question_answer)*100);
}
else
{
$answered_percentage = 0;
}
$progress_barHTML = '<span class="scor-ans-text">'.$total_answered_question.' of '.$total_question_answer.' answered</span>';
$progress_barHTML .= '<div class="scor-preload-pan"><span style="width: '.$answered_percentage.'%"></span></div>';
$return_array = array('all_submitted_question_answer'=>$all_submitted_question_answer,'res'=>'1','total_score' =>$total_score,'progress_barHTML'=>$progress_barHTML,'max_score'=>$total_max_marks,'thumbs_up'=>$thumbs_up);
echo json_encode($return_array);
//unset($_SESSION['all_submitted_question_answer']);
die;
}
add_action("wp_ajax_save_category_comments_temp", "save_category_comments_temp");
add_action("wp_ajax_nopriv_save_category_comments_temp", "save_category_comments_temp");
function save_category_comments_temp()
{
$categoryComments = $_REQUEST['categoryComments'];
$questionType = $_REQUEST['questionType'];
$save_data_db = $_REQUEST['save_data_db'];
$allcategoryHTML = '';
global $wpdb;
$tablename_scoringDetails = 'dt_scoring_details';
$tablename_comments = 'dt_scoring_category_comments';
if (isset($_SESSION['all_submitted_category_comments']))
{
$all_submitted_category_comments = $_SESSION['all_submitted_category_comments'];
if(!empty($all_submitted_category_comments))
{
if (array_key_exists($questionType,$all_submitted_category_comments))
{
unset($all_submitted_category_comments[$questionType]);
}
$all_submitted_category_comments[$questionType] = $categoryComments;
}
else
{
$all_submitted_category_comments[$questionType] = $categoryComments;
}
}
else
{
$all_submitted_category_comments = array();
$all_submitted_category_comments[$questionType] = $categoryComments;
}
$_SESSION['all_submitted_category_comments'] = $all_submitted_category_comments;
if($save_data_db == 1)
{
// Save all data in db
if (isset($_SESSION['contact_details_id']) || $_SESSION['contact_details_id'] != '')
{
$contact_details_id = $_SESSION['contact_details_id'];
if($contact_details_id != '')
{
$all_submitted_category_comments = array();
$all_submitted_question_answer = array();
if (isset($_SESSION['all_submitted_category_comments']))
{
$all_submitted_category_comments = $_SESSION['all_submitted_category_comments'];
}
if (isset($_SESSION['all_submitted_question_answer']))
{
$all_submitted_question_answer = $_SESSION['all_submitted_question_answer'];
}
// Insert Question answer value
if(!empty($all_submitted_question_answer))
{
foreach($all_submitted_question_answer as $catID=>$catdata)
{
$question_type_id = $catID;
if(!empty($catdata))
{
foreach($catdata as $questionID=>$answerval)
{
$question_id = $questionID;
$answerValue = $answerval['answerValue'];
$answerMarks = $answerval['answerMarks'];
$wpdb->insert( $tablename_scoringDetails, array(
'i_reviewer_id' => $contact_details_id,
'i_question_type_id' => $question_type_id,
'i_question_id' => $question_id,
's_answer' => $answerValue,
's_answer_marks' => $answerMarks,
'dt_created_on' => date('Y-m-d h:i:s') ),
array( '%s', '%s', '%s', '%s', '%s', '%s' )
);
}
}
}
}
// Insert Comments value
if(!empty($all_submitted_category_comments))
{
foreach($all_submitted_category_comments as $catID=>$commentsdata)
{
$question_type_id = $catID;
if($commentsdata != '')
{
$wpdb->insert( $tablename_comments, array(
'i_reviewer_id' => $contact_details_id,
'i_question_type_id' => $question_type_id,
's_comments' => $commentsdata,
'dt_created_on' => date('Y-m-d h:i:s') ),
array( '%s', '%s', '%s', '%s' )
);
}
}
}
$_SESSION['all_submitted_category_comments'] = array();
$_SESSION['all_submitted_question_answer'] = array();
$response = 1;
$_SESSION['contact_details_id'] = $contact_details_id;
$all_answered_marks_categorywise = $wpdb->get_results( "SELECT SUM(s_answer_marks) as total, i_question_type_id FROM `dt_scoring_details` WHERE i_reviewer_id = ".$contact_details_id." GROUP BY i_question_type_id" );
$all_total_score = 0;
$categorywise_total_marks = array();
$allcategoryHTML = '';
foreach($all_answered_marks_categorywise as $all_answered_marks_val)
{
$marks = $all_answered_marks_val->total;
$question_type_id = $all_answered_marks_val->i_question_type_id;
$total_max_marks = 0;
$all_questions = get_posts(array(
'post_type' => 'scroing_system',
'numberposts' => -1,
'tax_query' => array(
array(
'taxonomy' => 'scoring-category',
'field' => 'term_id',
'terms' => $question_type_id,
)
)
));
//echo '<pre>';print_r($all_questions);
if(!empty($all_questions))
{
$total_max_marks = ((count($all_questions))*100);
}
else
{
$total_max_marks = 0;
}
if($question_type_id == 54)
{
$manage_it_score = $marks;
$manage_it_max_score = $total_max_marks;
if($manage_it_score >0 && $manage_it_max_score >0)
{
$transforming_it_total_percentage = (($manage_it_score / $manage_it_max_score)*100);
if($manage_it_total_percentage >= 75)
{
$manage_it_thumbs_up = 1;
}
else
{
$manage_it_thumbs_up = 0;
}
}
else
{
$manage_it_thumbs_up = 0;
}
}
else if($question_type_id == 55)
{
$secure_it_score = $marks;
$secure_it_max_score = $total_max_marks;
if($secure_it_score >0 && $secure_it_max_score >0)
{
$secure_it_total_percentage = (($secure_it_score / $secure_it_max_score)*100);
if($secure_it_total_percentage >= 75)
{
$secure_it_thumbs_up = 1;
}
else
{
$secure_it_thumbs_up = 0;
}
}
else
{
$secure_it_thumbs_up = 0;
}
}
else if($question_type_id == 56)
{
$integrate_it_score = $marks;
$integrate_it_max_score = $total_max_marks;
if($integrate_it_score >0 && $integrate_it_max_score >0)
{
$integrate_it_total_percentage = (($integrate_it_score / $integrate_it_max_score)*100);
if($integrate_it_total_percentage >= 75)
{
$integrate_it_thumbs_up = 1;
}
else
{
$integrate_it_thumbs_up = 0;
}
}
else
{
$integrate_it_thumbs_up = 0;
}
}
else if($question_type_id == 57)
{
$transforming_it_score = $marks;
$transforming_it_max_score = $total_max_marks;
if($transforming_it_score >0 && $transforming_it_max_score >0)
{
$transforming_it_total_percentage = (($transforming_it_score / $transforming_it_max_score)*100);
if($transforming_it_total_percentage >= 75)
{
$transforming_it_thumbs_up = 1;
}
else
{
$transforming_it_thumbs_up = 0;
}
}
else
{
$transforming_it_thumbs_up = 0;
}
}
$category_details = get_term( $question_type_id, 'scoring-category' );
$category_name = $category_details->name;
$all_total_score = $all_total_score + $marks;
$allcategoryHTML .= '<div class="scoring-box"><div class="scoring-box-inner">';
$allcategoryHTML .= '<h4>'.$category_name.'</h4>';
$allcategoryHTML .= '<p>Score: <span>'.$marks.'</span></p>';
$allcategoryHTML .= '<div class="gauge-chart-final"><canvas id="scor-chart_final_'.$question_type_id.'" class="scor-chart_final"></canvas></div>';
//$allcategoryHTML .= '<div class="score-preload"><span>0</span><span>100</span></div></div></div>';
$allcategoryHTML .= '</div></div>';
}
$allcategoryHTML .= '<div class="clearfix"></div>';
$allcategoryHTML .= '<input type="hidden" name="contact_id" id="contact_id" value="'.$contact_details_id.'"/>';
if(count($all_answered_marks_categorywise) == 4)
{
$_SESSION['contact_details_id'] = '';
}
$total_max_score = ($manage_it_max_score + $secure_it_max_score + $integrate_it_max_score + $transforming_it_max_score);
}
else
{
$all_total_score = 0;
$total_max_score = 0;
}
}
else
{
$all_total_score = 0;
$total_max_score = 0;
}
}
else
{
$all_total_score = 0;
$total_max_score = 0;
}
$return_array = array('res'=>'1','all_total_score'=>$all_total_score,'allcategoryHTML'=>$allcategoryHTML,'manage_it_score'=>$manage_it_score,'secure_it_score'=>$secure_it_score,'integrate_it_score'=>$integrate_it_score,'transforming_it_score'=>$transforming_it_score,'integrate_it_thumbs_up'=>$integrate_it_thumbs_up,'secure_it_thumbs_up'=>$secure_it_thumbs_up,'transforming_it_thumbs_up'=>$transforming_it_thumbs_up,'manage_it_thumbs_up'=>$manage_it_thumbs_up);
echo json_encode($return_array);
die;
}
add_action("wp_ajax_save_final_comments_temp", "save_final_comments_temp");
add_action("wp_ajax_nopriv_save_final_comments_temp", "save_final_comments_temp");
function save_final_comments_temp()
{
$finalComments = $_REQUEST['finalComments'];
$contact_id = $_REQUEST['contact_id'];
global $wpdb;
$tablename = 'dt_scoring_contactdetails_master';
$wpdb->update(
'dt_scoring_contactdetails_master',
array(
's_finalComments' => $finalComments
),
array( 'i_id' => $contact_id ),
array(
'%s'
),
array( '%d' )
);
$return_array = array('res'=>'1');
echo json_encode($return_array);
die;
}
add_action("wp_ajax_save_user_data", "save_user_data");
add_action("wp_ajax_nopriv_save_user_data", "save_user_data");
function save_user_data()
{
$your_name = $_REQUEST['your_name'];
$your_email = $_REQUEST['your_email'];
$your_phone = $_REQUEST['your_phone'];
if($your_email != '' && $your_name != '')
{
// Save data in DB
global $wpdb;
$tablename = 'dt_scoring_contactdetails_master';
$tablename_scoringDetails = 'dt_scoring_details';
$tablename_comments = 'dt_scoring_category_comments';
$wpdb->insert( $tablename, array(
's_name' => $your_name,
's_email' => $your_email,
's_phone_number' => $your_phone,
'dt_created_on' => date('Y-m-d h:i:s') ),
array( '%s', '%s', '%s', '%s' )
);
$contact_details_id = $wpdb->insert_id;
if($contact_details_id != '')
{
$all_submitted_category_comments = array();
$all_submitted_question_answer = array();
if (isset($_SESSION['all_submitted_category_comments']))
{
$all_submitted_category_comments = $_SESSION['all_submitted_category_comments'];
}
if (isset($_SESSION['all_submitted_question_answer']))
{
$all_submitted_question_answer = $_SESSION['all_submitted_question_answer'];
}
// Insert Question answer value
if(!empty($all_submitted_question_answer))
{
foreach($all_submitted_question_answer as $catID=>$catdata)
{
$question_type_id = $catID;
if(!empty($catdata))
{
foreach($catdata as $questionID=>$answerval)
{
$question_id = $questionID;
$answerValue = $answerval['answerValue'];
$answerMarks = $answerval['answerMarks'];
$wpdb->insert( $tablename_scoringDetails, array(
'i_reviewer_id' => $contact_details_id,
'i_question_type_id' => $question_type_id,
'i_question_id' => $question_id,
's_answer' => $answerValue,
's_answer_marks' => $answerMarks,
'dt_created_on' => date('Y-m-d h:i:s') ),
array( '%s', '%s', '%s', '%s', '%s', '%s' )
);
}
}
}
}
// Insert Comments value
if(!empty($all_submitted_category_comments))
{
foreach($all_submitted_category_comments as $catID=>$commentsdata)
{
$question_type_id = $catID;
if($commentsdata != '')
{
$wpdb->insert( $tablename_comments, array(
'i_reviewer_id' => $contact_details_id,
'i_question_type_id' => $question_type_id,
's_comments' => $commentsdata,
'dt_created_on' => date('Y-m-d h:i:s') ),
array( '%s', '%s', '%s', '%s' )
);
}
}
}
$_SESSION['all_submitted_category_comments'] = array();
$_SESSION['all_submitted_question_answer'] = array();
$response = 1;
$all_answered_marks_categorywise = $wpdb->get_results( "SELECT SUM(s_answer_marks) as total, i_question_type_id FROM `dt_scoring_details` WHERE i_reviewer_id = ".$contact_details_id." GROUP BY i_question_type_id" );
$all_total_score = 0;
$categorywise_total_marks = array();
$allcategoryHTML = '';
foreach($all_answered_marks_categorywise as $all_answered_marks_val)
{
$marks = $all_answered_marks_val->total;
$question_type_id = $all_answered_marks_val->i_question_type_id;
$total_max_marks = 0;
$all_questions = get_posts(array(
'post_type' => 'scroing_system',
'numberposts' => -1,
'tax_query' => array(
array(
'taxonomy' => 'scoring-category',
'field' => 'term_id',
'terms' => $question_type_id,
)
)
));
//echo '<pre>';print_r($all_questions);
if(!empty($all_questions))
{
$total_max_marks = ((count($all_questions))*100);
}
else
{
$total_max_marks = 0;
}
if($question_type_id == 54)
{
$manage_it_score = $marks;
$manage_it_max_score = $total_max_marks;
}
else if($question_type_id == 55)
{
$secure_it_score = $marks;
$secure_it_max_score = $total_max_marks;
}
else if($question_type_id == 56)
{
$integrate_it_score = $marks;
$integrate_it_max_score = $total_max_marks;
}
else if($question_type_id == 57)
{
$transforming_it_score = $marks;
$transforming_it_max_score = $total_max_marks;
}
$category_details = get_term( $question_type_id, 'scoring-category' );
$category_name = $category_details->name;
$all_total_score = $all_total_score + $marks;
$allcategoryHTML .= '<div class="scoring-box"><div class="scoring-box-inner">';
$allcategoryHTML .= '<h4>'.$category_name.'</h4>';
$allcategoryHTML .= '<p>Score: <span>'.$marks.'</span></p>';
$allcategoryHTML .= '<div class="gauge-chart-final"><canvas id="scor-chart_final_'.$question_type_id.'" class="scor-chart_final"></canvas></div>';
//$allcategoryHTML .= '<div class="score-preload"><span>0</span><span>100</span></div></div></div>';
$allcategoryHTML .= '</div></div>';
}
$allcategoryHTML .= '<div class="clearfix"></div>';
$allcategoryHTML .= '<input type="hidden" name="contact_id" id="contact_id" value="'.$contact_details_id.'"/>';
$total_max_score = ($manage_it_max_score + $secure_it_max_score + $integrate_it_max_score + $transforming_it_max_score);
}
else
{
$response = 0;
$total_max_score = 0;
}
}
else
{
$response = 0;
$total_max_score = 0;
}
if($all_total_score >0 && $total_max_score >0)
{
$total_percentage = (($all_total_score / $total_max_score)*100);
if($total_percentage >= 75)
{
$thumbs_up = 1;
}
else
{
$thumbs_up = 0;
}
}
else
{
$thumbs_up = 0;
}
// Send Email
$to = $your_email;
$from = 'no-reply@concertium.com';
$headers = "From: <no-reply@concertium.com>";
$headers .= "Content-Type: text/html;";
$subject = 'Concertium Dt Score Results';
ob_start();
include 'dt_scroing_email_template_customer.php';
$mail_content = ob_get_contents();
ob_clean();
wp_mail( $to, $subject, $mail_content, $headers );
#$return_array = array('res'=>$response,'your_email'=>$your_email,'new_id'=>$lastid);
$return_array = array('res'=>$response,'all_total_score'=>$all_total_score,'allcategoryHTML'=>$allcategoryHTML,'manage_it_score'=>$manage_it_score,'secure_it_score'=>$secure_it_score,'integrate_it_score'=>$integrate_it_score,'transforming_it_score'=>$transforming_it_score,'manage_it_max_score'=>$manage_it_max_score,'secure_it_max_score'=>$secure_it_max_score,'integrate_it_max_score'=>$integrate_it_max_score,'transforming_it_max_score'=>$transforming_it_max_score,'total_max_score'=>$total_max_score,'thumbs_up' =>$thumbs_up);
echo json_encode($return_array);
die;
}
function dt_score_result_panel(){
add_menu_page('DT Score Results', 'DT Score Results', 'manage_options', 'dt-score-results', 'cb_dt_score_result');
}
add_action('admin_menu', 'dt_score_result_panel');
function cb_dt_score_result(){
ob_start();
include 'dt_scroing_result.php';
$all_content = ob_get_contents();
ob_clean();
echo $all_content;
}
add_filter( 'wp_mail_from_name', 'my_mail_from_name' );
function my_mail_from_name( $name ) {
return "Concertium";
}
function add_custom_font( $fonts ) {
$fonts['cooper_hewittbold'] = 'cooper_hewittbold';
$fonts['cooper_hewittbook'] = 'cooper_hewittbook';
$fonts['cooper_hewittmedium'] = 'cooper_hewittmedium';
$fonts['cooper_hewittmedium_italic'] = 'cooper_hewittmedium_italic';
//to add more fonts, just define they like this
//$fonts['my-font-family'] = 'my-font-name';
return $fonts;
}
add_filter( 'presscore_options_get_safe_fonts', 'add_custom_font' ,30 , 1 );
add_action( 'init', 'custom_post_type_cb' );
/**
* Register a slider post type.
*
* @link http://codex.wordpress.org/Function_Reference/register_post_type
*/
function custom_post_type_cb() {
// Payment Lists
$labels = array(
'name' => __( 'Payment Lists','your-plugin-textdomain' ),
'singular_name' => __( 'Payment Lists', 'your-plugin-textdomain' ),
'menu_name' => __( 'Payment Lists', 'your-plugin-textdomain' ),
'name_admin_bar' => __( 'Payment Lists', 'your-plugin-textdomain' ),
// 'add_new' => __( 'Add New', 'your-plugin-textdomain' ),
// 'add_new_item' => __( 'Add New Payment', 'your-plugin-textdomain' ),
// 'new_item' => __( 'New Payment', 'your-plugin-textdomain' ),
// 'edit_item' => __( 'Edit Payment', 'your-plugin-textdomain' ),
'view_item' => __( 'View Payment', 'your-plugin-textdomain' ),
'all_items' => __( 'All Payments', 'your-plugin-textdomain' ),
'search_items' => __( 'Search Payments', 'your-plugin-textdomain' ),
'parent_item_colon' => __( 'Parent Payment:', 'your-plugin-textdomain' ),
'not_found' => __( 'No Payment found.', 'your-plugin-textdomain' ),
'not_found_in_trash' => __( 'No Payment found in Trash.', 'your-plugin-textdomain' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'payment_list' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title' ),
'capabilities' => array(
'create_posts' => false,
'edit_published_posts' => false
),
'map_meta_cap' => true,
);
register_post_type( 'payment_list', $args );
flush_rewrite_rules();
}
add_filter( 'manage_edit-payment_list_columns', 'my_edit_payment_list_columns' ) ;
function my_edit_payment_list_columns( $columns ) {
$columns = array(
'title' => __( 'Customer Name' ),
'company' => __( 'Company' ),
'email' => __( 'Email' ),
'phone' => __( 'Phone' ),
'address' => __( 'Address' ),
'amount' => __( 'Amount' ),
'transaction' => __( 'Transaction Id' ),
'invoice' => __( 'Invoice' ),
'date' => __( 'Date' )
//'resend_receipt' => __( 'Resend Receipt' )
);
return $columns;
}
add_action( 'manage_payment_list_posts_custom_column', 'my_manage_payment_list_columns', 10, 2 );
function my_manage_payment_list_columns( $column, $post_id ) {
global $post;
switch( $column ) {
/*-------------- If displaying the 'email' column.-------- */
case 'email' :
/* Get the post meta. */
$email = get_post_meta( $post_id, 'email', true );
/* If no email is found, output a default message. */
if ( empty( $email ) )
echo __( 'Unknown' );
/* If there is a email, append 'minutes' to the text string. */
else
printf( $email );
/*--------------------- End 'email' column.------------------ */
/*-------------- If displaying the 'company' column.-------- */
break;
case 'company' :
/* Get the post meta. */
$company = get_post_meta( $post_id, 'company', true );
/* If no duration is found, output a default message. */
if ( empty( $company ) )
echo __( 'Unknown' );
/* If there is a duration, append 'minutes' to the text string. */
else
printf( $company );
/*--------------------- End 'company' column.------------------ */
/*-------------- If displaying the 'phone' column.-------- */
break;
case 'phone' :
/* Get the post meta. */
$phone = get_post_meta( $post_id, 'phone_no', true );
/* If no duration is found, output a default message. */
if ( empty( $phone ) )
echo __( 'Unknown' );
/* If there is a duration, append 'minutes' to the text string. */
else
printf( $phone );
/*--------------------- End 'phone' column.------------------ */
/*-------------- If displaying the 'address' column.-------- */
break;
case 'address' :
/* Get the post meta. */
$address = get_post_meta( $post_id, 'address', true );
/* If no duration is found, output a default message. */
if ( empty( $address ) )
echo __( 'Unknown' );
/* If there is a duration, append 'minutes' to the text string. */
else
printf( $address );
/*--------------------- End 'address' column.------------------ */
/*-------------- If displaying the 'amount' column.-------- */
break;
case 'amount' :
/* Get the post meta. */
$amount = get_post_meta( $post_id, 'amount', true );
/* If no duration is found, output a default message. */
if ( empty( $amount ) )
echo __( 'Unknown' );
/* If there is a duration, append 'minutes' to the text string. */
else
echo '$'.$amount;
/*--------------------- End 'amount' column.------------------ */
/*-------------- If displaying the 'transaction' column.-------- */
break;
case 'transaction' :
/* Get the post meta. */
$transaction_id = get_post_meta( $post_id, 'transaction_id', true );
/* If no duration is found, output a default message. */
if ( empty( $transaction_id ) )
echo __( 'Unknown' );
/* If there is a duration, append 'minutes' to the text string. */
else
printf( $transaction_id );
/*--------------------- End 'transaction' column.------------------ */
/*-------------- If displaying the 'Invoice' column.-------- */
break;
case 'invoice' :
/* Get the post meta. */
$invoice = get_post_meta( $post_id, 'invoice_number', true );
/* If no duration is found, output a default message. */
if ( empty( $invoice ) )
echo __( 'Unknown' );
/* If there is a duration, append 'minutes' to the text string. */
else
printf( $invoice );
/*--------------------- End 'Invoice' column.------------------ */
break;
default :
break;
}
}
/**
* Snippet Name: Hide VIEW button on post edit screen for custom post types
* Snippet URL: http://www.wpcustoms.net/snippets/hide-view-button-post-edit-screen-custom-post-types/
*/
function wpc_remove_row_actions( $actions )
// reference:
// $actions['edit']
// $actions['inline hide-if-no-js']
// $actions['trash']
// $actions['view']
{
if( get_post_type() === 'payment_list' ) // choose the post type where you want to hide the button
unset( $actions['view'] ); // this hides the VIEW button on your edit post screen
return $actions;
}
add_filter( 'post_row_actions', 'wpc_remove_row_actions', 10, 1 );
function getCCType($cardNumber) {
// Remove non-digits from the number
$cardNumber = preg_replace('/\D/', '', $cardNumber);
// Validate the length
$len = strlen($cardNumber);
switch($cardNumber) {
case(preg_match ('/^4/', $cardNumber) >= 1):
return 'Visa';
case(preg_match ('/^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}/', $cardNumber) >= 1):
return 'Mastercard';
case(preg_match ('/^3(?:0[0-5]|[68])/', $cardNumber) >= 1):
return 'Diners Club';
case(preg_match ('/^6(?:011|5)/', $cardNumber) >= 1):
return 'Discover';
case(preg_match ('/^(?:2131|1800|35\d{3})/', $cardNumber) >= 1):
return 'JCB';
case(preg_match ('/^3[47][0-9]{5,}/', $cardNumber) >= 1):
return 'American Express';
default:
return 'Unknown';
break;
}
}
if (!function_exists('extend_admin_search')) {
add_action('admin_init', 'extend_admin_search');
/**
* hook the posts search if we're on the admin page for our type
*/
function extend_admin_search() {
global $typenow;
if ($typenow === 'payment_list') {
add_filter('posts_search', 'posts_search_custom_post_type', 10, 2);
}
}
/**
* add query condition for custom meta
* @param string $search the search string so far
* @param WP_Query $query
* @return string
*/
function posts_search_custom_post_type($search, $query) {
global $wpdb;
if ($query->is_main_query() && !empty($query->query['s'])) {
$sql = "
or exists (
select * from {$wpdb->postmeta} where post_id={$wpdb->posts}.ID
and meta_key in ('company','transaction_id')
and meta_value like %s
)
";
$like = '%' . $wpdb->esc_like($query->query['s']) . '%';
$search = preg_replace("#\({$wpdb->posts}.post_title LIKE [^)]+\)\K#",
$wpdb->prepare($sql, $like), $search);
}
return $search;
}
}
/**
* Add attachment to contact form 7
*/
// add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
// function mycustom_wpcf7_mail_components( $components ) {
// // if($template_name != 'template-parts/industry-pages.php') {
// $page_id = get_the_ID();
// $case_study = get_field( "case_study", $page_id );
// if($case_study != '') {
// $components['attachments'][] = $case_study;
// return $components;
// }
// // }
// }
// add_action('wpcf7_before_send_mail','send_pdf');
// function send_pdf( $cf7 ) {
// global $post;
// $id = $cf7->id();
// if ($id==4951){
// $submission = WPCF7_Submission::get_instance();
// $data = $submission->get_posted_data();
// echo '<pre>'; print_r($post);
// $page_id = get_the_ID();
// echo $id = $post->id;
// echo 'here';
// $case_study = get_field( "case_study", $page_id );
// echo '<pre>'; print_r($case_study); exit;
// $submission = WPCF7_Submission::get_instance();
// $submission->add_uploaded_file('Case Study', $case_study);
// }
// }
// add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );
// function mycustom_wpcf7_mail_components( $components ) {
// echo 'here';
// echo $page_id = get_the_ID(); exit;
// $components['attachments'][] = get_template_directory().'/Website-Changes-Mockup-Aug-26-2020.pptx'; // PDF Path
// return $components;
// }