File: /home/kochikidswysewor/public_html/wp-content/themes/children-charity-child/functions.php
<?php
/**
* @package WordPress
* @subpackage Children Charity
* @version 1.0.8
*
* Main Theme Functions File
* Created by CMSMasters
*
*/
/*** START EDIT THEME PARAMETERS HERE ***/
function children_charity_enqueue_styles() {
wp_enqueue_style('children-charity-child-style', get_stylesheet_uri(), array(), '1.0.0', 'screen, print');
}
add_action('wp_enqueue_scripts', 'children_charity_enqueue_styles', 11);
// Theme Settings System Fonts List
if (!function_exists('children_charity_system_fonts_list')) {
function children_charity_system_fonts_list() {
$fonts = array(
"Arial, Helvetica, 'Nimbus Sans L', sans-serif" => 'Arial',
"Calibri, 'AppleGothic', 'MgOpen Modata', sans-serif" => 'Calibri',
"'Trebuchet MS', Helvetica, Garuda, sans-serif" => 'Trebuchet MS',
"'Comic Sans MS', Monaco, 'TSCu_Comic', cursive" => 'Comic Sans MS',
"Georgia, Times, 'Century Schoolbook L', serif" => 'Georgia',
"Verdana, Geneva, 'DejaVu Sans', sans-serif" => 'Verdana',
"Tahoma, Geneva, Kalimati, sans-serif" => 'Tahoma',
"'Lucida Sans Unicode', 'Lucida Grande', Garuda, sans-serif" => 'Lucida Sans',
"'Times New Roman', Times, 'Nimbus Roman No9 L', serif" => 'Times New Roman',
"'Courier New', Courier, 'Nimbus Mono L', monospace" => 'Courier New',
);
return $fonts;
}
}
// Theme Settings Text Decorations List
if (!function_exists('children_charity_text_decoration_list')) {
function children_charity_text_decoration_list() {
$list = array(
'none' => esc_html__('none', 'children-charity'),
'underline' => esc_html__('underline', 'children-charity'),
'overline' => esc_html__('overline', 'children-charity'),
'line-through' => esc_html__('line-through', 'children-charity'),
);
return $list;
}
}
// Theme Settings Custom Color Schemes
if (!function_exists('children_charity_custom_color_schemes_list')) {
function children_charity_custom_color_schemes_list() {
$list = array(
'first' => esc_html__('Custom 1', 'children-charity'),
'second' => esc_html__('Custom 2', 'children-charity'),
'third' => esc_html__('Custom 3', 'children-charity'),
'fourth' => esc_html__('Custom 4', 'children-charity')
);
return apply_filters('children_charity_custom_color_schemes_list_filter', $list);
}
}
/*** STOP EDIT THEME PARAMETERS HERE ***/
// Require Files Function
if (!function_exists('children_charity_locate_template')) {
function children_charity_locate_template($template_names, $require_once = true, $load = true) {
$located = '';
foreach ((array) $template_names as $template_name) {
if (!$template_name) {
continue;
}
if (file_exists(get_stylesheet_directory() . '/' . $template_name)) {
$located = get_stylesheet_directory() . '/' . $template_name;
break;
} elseif (file_exists(get_template_directory() . '/' . $template_name)) {
$located = get_template_directory() . '/' . $template_name;
break;
}
}
if ($load && $located != '') {
if ($require_once) {
require_once($located);
} else {
require($located);
}
}
return $located;
}
}
// CMSMasters Content Composer Plugin Compatibility
define('CMSMASTERS_CONTENT_COMPOSER', true);
// CMSMasters Donations Plugin Compatibility
define('CMSMASTERS_DONATIONS', true);
// CMSMasters Events Schedule Plugin Compatibility
define('CMSMASTERS_EVENTS_SCHEDULE', false);
// CMSMasters Contact Form Builder Plugin Compatibility
define('CMSMASTERS_CONTACT_FORM_BUILDER', true);
// CMSMasters Mega Menu Plugin Compatibility
define('CMSMASTERS_MEGA_MENU', true);
// CMSMasters Importer Compatibility
define('CMSMASTERS_IMPORTER', true);
// CMSMasters Custom Fonts Compatibility
define('CMSMASTERS_CUSTOM_FONTS', true);
// CMSMasters Sermons Plugin Compatibility
define('CMSMASTERS_SERMONS', false);
// MP Timetable and Event Schedule Plugin Compatibility
define('CMSMASTERS_MP_TIMETABLE', class_exists('Mp_Time_Table') ? true : false);
// WooCommerce Plugin Compatibility
define('CMSMASTERS_WOOCOMMERCE', class_exists('woocommerce') ? false : false);
// The Events Calendar Plugin Compatibility
define('CMSMASTERS_TRIBE_EVENTS', class_exists('Tribe__Events__Main') ? true : false);
// Timetable Responsive Schedule For WordPress Plugin Compatibility
define('CMSMASTERS_TIMETABLE', function_exists('timetable_events_init') ? false : false);
// LearnPress Plugin Compatibility
define('CMSMASTERS_LEARNPRESS', class_exists('LearnPress') ? false : false);
// WordPress Event Ticketing Plugin Compatibility
define('CMSMASTERS_TC_EVENTS', class_exists('TC') ? false : false);
// Instagram Feed Plugin Compatibility
define('CMSMASTERS_INSTAGRAM_FEED', function_exists('sb_instagram_activate') ? false : false);
// MailPoet Plugin Compatibility
define('CMSMASTERS_MAILPOET', (class_exists('WYSIJA') || class_exists('\MailPoet\Config\Initializer')) ? true : false);
// Theme Style Compatibility
define('CMSMASTERS_THEME_STYLE_COMPATIBILITY', false);
// Theme Style
define('CMSMASTERS_THEME_STYLE', (CMSMASTERS_THEME_STYLE_COMPATIBILITY && get_option('cmsmasters_children-charity_theme_style') ? get_option('cmsmasters_children-charity_theme_style') : ''));
// Theme Colored Categories Compatibility
define('CMSMASTERS_COLORED_CATEGORIES', true);
// Theme Categories Icon Compatibility
define('CMSMASTERS_CATEGORIES_ICON', true);
// Theme Projects Compatibility
// define('CMSMASTERS_PROJECT_COMPATIBLE', true); //Profile Module
// Theme Profiles Compatibility
// define('CMSMASTERS_PROFILE_COMPATIBLE', true);
// Theme Developer Mode
define('CMSMASTERS_DEVELOPER_MODE', false);
// Change FS Method
if (!defined('FS_METHOD')) {
define('FS_METHOD', 'direct');
}
// Theme Settings All Theme Styles
if (!function_exists('children_charity_all_theme_styles')) {
function children_charity_all_theme_styles() {
$out = array(
'Default|',
'Theme Style 1|1',
'Theme Style 2|2'
);
return $out;
}
}
// Theme Settings All Color Schemes List
if (!function_exists('children_charity_all_color_schemes_list')) {
function children_charity_all_color_schemes_list() {
$list = array(
'default' => esc_html__('Default', 'children-charity'),
'header' => esc_html__('Header', 'children-charity'),
'navigation' => esc_html__('Navigation', 'children-charity'),
'header_top' => esc_html__('Header Top', 'children-charity'),
'footer' => esc_html__('Footer', 'children-charity')
);
$out = array_merge($list, children_charity_custom_color_schemes_list());
return apply_filters('cmsmasters_all_color_schemes_list_filter', $out);
}
}
// CMSMasters Framework Directories Constants
define('CMSMASTERS_FRAMEWORK', get_template_directory() . '/framework');
define('CMSMASTERS_ADMIN', CMSMASTERS_FRAMEWORK . '/admin');
define('CMSMASTERS_SETTINGS', CMSMASTERS_ADMIN . '/settings');
define('CMSMASTERS_OPTIONS', CMSMASTERS_ADMIN . '/options');
define('CMSMASTERS_ADMIN_INC', CMSMASTERS_ADMIN . '/inc');
define('CMSMASTERS_CLASS', CMSMASTERS_FRAMEWORK . '/class');
define('CMSMASTERS_FUNCTION', CMSMASTERS_FRAMEWORK . '/function');
define('CMSMASTERS_VARS', get_template_directory() . '/theme-vars');
define('CMSMASTERS_VARS_STYLE', CMSMASTERS_VARS . '/theme-style' . CMSMASTERS_THEME_STYLE);
define('CMSMASTERS_DEMO_FILES_PATH', CMSMASTERS_VARS_STYLE . '/admin/demo-content/');
// Load Framework Parts
if (class_exists('Cmsmasters_Theme_Importer')) {
require_once(CMSMASTERS_VARS_STYLE . '/admin/demo-content-importer.php');
}
require_once(CMSMASTERS_VARS_STYLE . '/admin/theme-settings-defaults.php');
require_once(CMSMASTERS_CLASS . '/browser.php');
require_once(CMSMASTERS_ADMIN_INC . '/config-functions.php');
require_once(CMSMASTERS_FUNCTION . '/general-functions.php');
require_once(get_template_directory() . '/theme-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/theme-functions.php');
require_once(CMSMASTERS_VARS_STYLE . '/theme-vars-functions.php');
require_once(CMSMASTERS_VARS . '/plugin-activator.php');
require_once(CMSMASTERS_SETTINGS . '/cmsmasters-theme-settings.php');
require_once(CMSMASTERS_OPTIONS . '/cmsmasters-theme-options.php');
require_once(CMSMASTERS_ADMIN_INC . '/admin-scripts.php');
require_once(CMSMASTERS_FUNCTION . '/breadcrumbs.php');
require_once(CMSMASTERS_FUNCTION . '/likes.php');
require_once(CMSMASTERS_FUNCTION . '/views.php');
require_once(CMSMASTERS_FUNCTION . '/pagination.php');
$cmsmasters_wp_version = get_bloginfo('version');
if (version_compare($cmsmasters_wp_version, '5', '>=') || function_exists('is_gutenberg_page')) {
require_once(get_template_directory() . '/gutenberg/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-module-functions.php');
}
// Theme Colored Categories functions
if (CMSMASTERS_COLORED_CATEGORIES) {
require_once(CMSMASTERS_FUNCTION . '/theme-colored-categories.php');
}
// Theme Categories Icon functions
if (CMSMASTERS_CATEGORIES_ICON) {
require_once(CMSMASTERS_FUNCTION . '/theme-categories-icon.php');
}
// CMSMASTERS Donations functions
if (CMSMASTERS_DONATIONS && class_exists('Cmsmasters_Donations')) {
require_once(get_template_directory() . '/cmsmasters-donations/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
}
// CMSMasters Events Schedule functions
if (CMSMASTERS_EVENTS_SCHEDULE && class_exists('Cmsmasters_Events_Schedule')) {
require_once(get_template_directory() . '/cmsmasters-events-schedule/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
}
// CMSMasters Sermons functions
if (CMSMASTERS_SERMONS && class_exists('Cmsmasters_Sermons')) {
require_once(get_template_directory() . '/cmsmasters-sermons/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
}
// Woocommerce functions
if (CMSMASTERS_WOOCOMMERCE) {
require_once(get_template_directory() . '/woocommerce/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
}
// Tribe Events functions
if (CMSMASTERS_TRIBE_EVENTS) {
require_once(get_template_directory() . '/tribe-events/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
}
// Timetable functions
if (CMSMASTERS_TIMETABLE) {
require_once(get_template_directory() . '/timetable/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
}
// MP Timetable functions
if (CMSMASTERS_MP_TIMETABLE) {
require_once(get_template_directory() . '/mp-timetable/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
}
// LearnPress functions
if (CMSMASTERS_LEARNPRESS) {
require_once(get_template_directory() . '/learnpress/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
add_filter('learn_press_template_path', function() {return 'learnpress/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/templates';});
}
// TC Events functions
if (CMSMASTERS_TC_EVENTS) {
require_once(get_template_directory() . '/tc-events/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
}
// Instagram Feed functions
if (CMSMASTERS_INSTAGRAM_FEED) {
require_once(get_template_directory() . '/instagram-feed/cmsmasters-framework/theme-style' . CMSMASTERS_THEME_STYLE . '/cmsmasters-plugin-functions.php');
}
// Load Theme Local File
if (!function_exists('children_charity_load_theme_textdomain')) {
function children_charity_load_theme_textdomain() {
load_theme_textdomain('children-charity', CMSMASTERS_VARS . '/languages');
}
}
// Load Theme Local File Action
if (!has_action('after_setup_theme', 'children_charity_load_theme_textdomain')) {
add_action('after_setup_theme', 'children_charity_load_theme_textdomain');
}
// Framework Activation & Data Import
if (!function_exists('children_charity_theme_activation')) {
function children_charity_theme_activation() {
if (get_option('cmsmasters_active_theme') != 'children-charity') {
add_option('cmsmasters_active_theme', 'children-charity', '', 'yes');
children_charity_add_global_options();
children_charity_add_global_icons();
wp_redirect(esc_url(admin_url('admin.php?page=cmsmasters-settings&upgraded=true')));
}
}
}
add_action('after_switch_theme', 'children_charity_theme_activation');
// Framework Deactivation
if (!function_exists('children_charity_theme_deactivation')) {
function children_charity_theme_deactivation() {
delete_option('cmsmasters_active_theme');
}
}
add_action('switch_theme', 'children_charity_theme_deactivation');
// Plugin Activation Regenerate Styles
if (!function_exists('children_charity_plugin_activation')) {
function children_charity_plugin_activation($plugin, $network_activation) {
update_option('cmsmasters_plugin_activation', 'true');
if ($plugin == 'classic-editor/classic-editor.php') {
update_option('classic-editor-replace', 'no-replace');
}
}
}
add_action('activated_plugin', 'children_charity_plugin_activation', 10, 2);
if (!function_exists('children_charity_plugin_activation_regenerate')) {
function children_charity_plugin_activation_regenerate() {
if (!get_option('cmsmasters_plugin_activation')) {
add_option('cmsmasters_plugin_activation', 'false');
}
if (get_option('cmsmasters_plugin_activation') != 'false') {
children_charity_regenerate_styles();
update_option('cmsmasters_plugin_activation', 'false');
}
}
}
add_action('init', 'children_charity_plugin_activation_regenerate');
/*function children_charity_run_reinit_import_options($post_id, $key, $value) {
if (get_post_type($post_id) == 'post' && !get_post_meta($post_id, 'cmsmasters_heading', true)) {
$custom_meta_fields = children_charity_get_custom_general_meta_fields();
$custom_post_meta_fields = children_charity_get_custom_post_meta_fields();
$custom_all_meta_fields = array_merge($custom_post_meta_fields, $custom_meta_fields);
foreach ($custom_all_meta_fields as $field) {
if (
$field['type'] != 'tabs' &&
$field['type'] != 'tab_start' &&
$field['type'] != 'tab_finish' &&
$field['type'] != 'content_start' &&
$field['type'] != 'content_finish'
) {
update_post_meta($post_id, $field['id'], $field['std']);
}
}
}
if($key == 'cmsmasters_composer_show' && $value == true) {
if(get_post_meta($post_id, 'cmsmasters_gutenberg_show', true)) {
update_post_meta($post_id, 'cmsmasters_gutenberg_show', true);
} else {
add_post_meta($post_id, 'cmsmasters_gutenberg_show', true);
}
}
}
add_action('import_post_meta', 'children_charity_run_reinit_import_options', 10, 3);*/
include( get_stylesheet_directory() . '/shortcodes/ourchildren.php' );
/**
* Manage Our Children Module Module Starts Here!
*/
add_action('init', 'cptui_register_children');
function cptui_register_children() {
register_post_type('children', array(
'label' => 'Our Cases',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'our-children', 'with_front' => false ),
'query_var' => true,
// 'exclude_from_search' => false,
'supports' => array('title', 'editor' ,'thumbnail'),
'taxonomies' => array('children_categories'),
'labels' => array (
'name' => 'Our Cases',
'singular_name' => 'Our Cases',
'menu_name' => 'Our Cases',
'all_items' => 'All Cases',
'add_new' => 'Add New Case',
'add_new_item' => 'Add New Case',
'edit' => 'Edit',
'edit_item' => 'Edit Case',
'new_item' => 'New Case',
'view' => 'View Case',
'view_item' => 'View Case',
'search_items' => 'Search Case',
'not_found' => 'No Cases Found',
'not_found_in_trash' => 'No Cases Found in Trash',
'parent' => 'Parent Our Cases',)
)
);
}
add_action('init', 'cptui_register_children_categories');
function cptui_register_children_categories() {
register_taxonomy( 'children_categories',array (
0 => 'children',
),
array( 'hierarchical' => true,
'query_var' => 'children_categories',
'public' => false,
'rewrite' => array('slug' => 'children_categories', 'hierarchical' => true,'with_front' => false ),
'_builtin' => false,
'label' => 'Our Causes',
'show_ui' => true,
'show_admin_column' => true,
'labels' => array (
'search_items' => 'Our Causes',
'all_items' => 'Our Causes',
'add_new_item' => 'Add New Cause',
'edit_item' => 'Edit Our Cause',
'back_to_items' => 'Back to Causes')
) );
}
add_filter( 'manage_edit-children_columns', 'my_edit_children_columns' ) ;
function my_edit_children_columns( $columns )
{
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Title' ),
'answer' => __( 'Case' ),
'taxonomy-children_categories' => __( 'Cause'),
'status' => __( 'Status' ),
'date' => __( 'Date' )
);
return $columns;
}
add_action( 'manage_children_posts_custom_column', 'my_manage_children_columns', 10, 2 );
function my_manage_children_columns( $column, $post_id ) {
global $post;
$custom = get_post_custom($post->ID);
$answer = apply_filters( 'the_content', $post->post_content );
$status = get_field('status',$post->ID);
switch( $column ) {
case 'answer' :
$answer = wordLimit($answer,150);
echo $answer;
break;
default :
break;
case 'status' :
echo $status;
break;
}
}
/**
* Manage Our Children Module Ends Here!
*/
/**
* Current URL function
*/
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
/**
* Wordlimit Starts Here
*/
function wordLimit($string,$limitNum){
if (strlen($string) > $limitNum){
$string = substr($string, 0, strrpos(substr($string, 0, $limitNum), ' ')) . '...';
}
return $string;
}
/**
* Limited Sentence Starts Here
*/
function limited_sentences($text,$limit){
$text = preg_replace('/<ul[^>]*>([\s\S]*?)<\/ul[^>]*>/', '', $text);
//$text = preg_replace('/<ol[^>]*>([\s\S]*?)<\/ol[^>]*>/', '', $text);
$text = preg_replace('/<h1[^>]*>([\s\S]*?)<\/h1[^>]*>/', '', $text);
$text = preg_replace('/<h2[^>]*>([\s\S]*?)<\/h2[^>]*>/', '', $text);
$text = preg_replace('/<h3[^>]*>([\s\S]*?)<\/h3[^>]*>/', '', $text);
$text = preg_replace('/<h4[^>]*>([\s\S]*?)<\/h4[^>]*>/', '', $text);
$text = preg_replace('/<h5[^>]*>([\s\S]*?)<\/h5[^>]*>/', '', $text);
$text = preg_replace('/<h6[^>]*>([\s\S]*?)<\/h6[^>]*>/', '', $text);
$text = strip_tags($text);
$text1=$text;
$fl_stp_count = substr_count($text, '.');$qn_count = substr_count($text, '?');$excla_count = substr_count($text, '!');
$total_count = $fl_stp_count + $qn_count + $excla_count;
$limit_charcount = 0;$limited_text_last = '';
for($i=1;$i<=$total_count;$i++){
preg_match("/^([^.!?]*[\.!?]+){0,$i}/", strip_tags($text), $abstract);
$limited_text = $abstract[0]; $limit_charcount = strlen($limited_text);
if( $limit_charcount<=$limit){ $limited_text_last = $abstract[0];}
}
if($limited_text_last==''){
$limited_text_last = ($limit>=strlen($text) ? substr($text, 0, $limit) : substr($text, 0, strrpos(substr($text, 0, $limit), ' ')));
$lastcharacter = substr($limited_text_last, -1);
if($limited_text_last!=''){
if($lastcharacter=='.'){$limited_text_last = $limited_text_last . '..';}else if($lastcharacter=='?' ||$lastcharacter=='!'){$limited_text_last = $limited_text_last;}else{
if($limit<=strlen($text)) { $limited_text_last = $limited_text_last . '...'; } }
}
}
$lastcharacterdr = substr($limited_text_last, -3);
if($lastcharacterdr=='Dr.' || $lastcharacterdr=='Mr.' )
{
$fl_stp_count = substr_count($text1, '.');$qn_count = substr_count($text1, '?');$excla_count = substr_count($text1, '!');
$total_count = $fl_stp_count + $qn_count + $excla_count;
$limit_charcount = 0;$limited_text_last = '';
for($i=1;$i<=$total_count+1;$i++){
preg_match("/^([^.!?]*[\.!?]+){0,2}/", strip_tags($text1), $abstract);
$limited_text = $abstract[0]; $limit_charcount = strlen($limited_text);
if( $limit_charcount<=$limit){ $limited_text_last = $abstract[0];}
}
if($limited_text_last==''){
$limited_text_last = ($limit>=strlen($text) ? substr($text, 0, $limit) : substr($text, 0, strrpos(substr($text, 0, $limit), ' ')));
$lastcharacter = substr($limited_text_last, -1);
if($limited_text_last!=''){
if($lastcharacter=='.'){$limited_text_last = $limited_text_last . '..';}else if($lastcharacter=='?' ||$lastcharacter=='!'){$limited_text_last = $limited_text_last;}else{
if($limit<=strlen($text)) { $limited_text_last = $limited_text_last . '...'; } }
}
}
}
return $limited_text_last;
}
/**
* Set Image size for images.
*/
add_image_size( 'child_image', 270, 270);
add_image_size( 'child_image_cr', 270, 270, true); //Image size for Blog Listing page
/**
* Title Mandatory Starts here.
*/
add_filter('gettext','custom_enter_title');
function custom_enter_title( $input ) {
global $post_type;
if( is_admin() && 'Add title' == $input && 'children' == $post_type )
return 'Enter Child Name Here';
return $input;
}
function force_post_title_init()
{
wp_enqueue_script('jquery');
}
function force_post_title_children()
{
echo "<script type='text/javascript'>\n";
echo "jQuery('#publish').click(function(){
jQuery('.error').remove();
var testervar = jQuery('[id^=\"titlediv\"]')
.find('#title');
var content = jQuery('[id^=\"wp-content-editor-container\"]')
.find('#content');
if (testervar.val().length < 1)
{
setTimeout(\"jQuery('#ajax-loading').css('visibility', 'hidden');\", 100);
if(jQuery('[id^=\"title-prompt-text\"]').html()==\"Enter Child Name Here\"){
jQuery('[id^=\"titlediv\"]').prepend('<div style=\"background:#F55E4F;color:#FFF;padding:5px;\" class=\"error acf-notice -error acf-error-message\">Child Name is required here</div>');
}
jQuery('#title').focus();
setTimeout(\"jQuery('#publish').removeClass('button-primary-disabled');\", 100);
return false;
}
if (content.val().length < 1)
{
if(jQuery('[id^=\"title-prompt-text\"]').html()==\"Enter Child Name Here\"){
setTimeout(\"jQuery('#ajax-loading').css('visibility', 'hidden');\", 100);
jQuery('[id^=\"wp-content-wrap\"]').prepend('<div style=\"background:#F55E4F;color:#FFF;padding:5px;\" class=\"error acf-notice -error acf-error-message\">Description is required here</div>');
}
jQuery('#content').focus();
setTimeout(\"jQuery('#publish').removeClass('button-primary-disabled');\", 100);
return false;
}
});
";
echo "</script>\n";
}
global $post_type;
if(($_GET['post_type'] == 'children') || ($post_type == 'children')){
add_action('admin_init', 'force_post_title_init');
add_action('edit_form_advanced', 'force_post_title_children');
add_action('edit_page_form', 'force_post_title_children');
}
remove_filter('pre_user_description', 'wp_filter_kses');
function set_default_object_terms( $post_id, $post ) {
if ( 'publish' === $post->post_status && $post->post_type === 'children' ) {
$defaults = array(
'children_categories' => array('female')
);
$taxonomies = get_object_taxonomies( $post->post_type );
foreach ( (array) $taxonomies as $taxonomy ) {
$terms = wp_get_post_terms( $post_id, $taxonomy );
if ( empty( $terms ) && array_key_exists( $taxonomy, $defaults ) ) {
wp_set_object_terms( $post_id, $defaults[$taxonomy], $taxonomy );
}
}
}
}
add_action( 'save_post', 'set_default_object_terms', 0, 2 );
add_action('after_setup_theme', 'remove_admin_bar');
// Function to remove admin login bar from user side
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
//Function to hide a repeater sub field from admin side
function my_theme_hide_acf_sponsors_admin_head() {
?>
<style>
.acf-postbox *[data-key="field_5e280ed9169cc"] {
display: none !important;
}
</style>
<?php
}
//add_action('acf/input/admin_head', 'my_theme_hide_acf_sponsors_admin_head');
//Function to style admin
function my_acf_admin_head() {
?>
<style type="text/css">
.acf-flexible-content .layout .acf-fc-layout-handle {
/*background-color: #00B8E4;*/
background-color: #202428;
color: #eee;
}
.acf-repeater.-row > table > tbody > tr > td,
.acf-repeater.-block > table > tbody > tr > td {
border-top: 2px solid #202428;
}
.acf-repeater .acf-row-handle {
vertical-align: top !important;
padding-top: 16px;
}
.acf-repeater .acf-row-handle span {
font-size: 20px;
font-weight: bold;
color: #202428;
}
.imageUpload img {
width: 75px;
}
.acf-repeater .acf-row-handle .acf-icon.-minus {
top: 30px;
}
</style>
<?php
}
add_action('acf/input/admin_head', 'my_acf_admin_head');
add_action('template_redirect', 'blog_redirect', 1);
function blog_redirect() {
$dir = $_SERVER['REQUEST_URI'];
$path = explode('/', $dir);
$file = explode('?', $path[1]);
header("HTTP/1.1 200 OK");
switch ($file[0]) {
case 'print-invoice' :
include( get_template_directory() . '/print-invoice.php' );
exit();
break;
default:
break;
}
}
function custom_add_user_id_column($columns) {
$columns['user_status'] = 'Status';
return $columns;
}
add_filter('manage_users_columns', 'custom_add_user_id_column');
function custom_show_user_id_column_content($value, $column_name, $user_id) {
$status = get_field('user_status', 'user_'. $user_id );
if ( 'user_status' == $column_name )
return $status;
return $value;
}
add_filter('manage_users_custom_column', 'custom_show_user_id_column_content', 10, 3);
//-------------------Manage shortcodes-------------------------------//
include( get_stylesheet_directory().'/shortcodes/our-dontation-lists.php' );
// add_action( 'profile_update', 'my_profile_update', 10, 2 );
// function my_profile_update( $user_id, $old_user_data ) {
// $status = ($_POST['acf']['field_63c7f100ce598'] == 'Active') ? 1 : 0 ;
// if($status != $old_user_data->user_status) {
// if($status == 1) {
// $admin_email = get_option("admin_email"); //admin email fetch
// $body_ = "Kochi Kids -Account Activated";
// $body =
// '<table width="700px" cellpadding="0" cellspacing="0" style="width:700px;
// border-left:1px solid #171717;
// border-top:1px solid #171717;
// font-family:Arial, Helvetica, sans-serif;
// font-size:13px;
// color:#000;
// margin:0 auto;">
// <tbody><tr style="background:#fff;">
// <td colspan="2" style="padding:0px !important;border-right:1px solid #171717;
// border-bottom:0px solid #171717;
// ">
// <a href="'. get_site_url().'" title="Kochi Kids" style="font-family:Arial, Helvetica, sans-serif;
// font-size:13px;
// color:#000;
// text-decoration:underline;">
// <img src="'.get_template_directory_uri().'/img/mail-template.jpg" alt="Kochi Kids"></a>
// </td>
// </tr>
// <tr>
// <td colspan="2" style="border-right:1px solid #171717;
// border-bottom:1px solid #171717;
// padding:5px;">
// Hi,
// <br>
// <br>
// Thank You,Your account is acivated.<br>
// <br> <br>
// </td>
// </tr> <tr>
// <td colspan="2" class="footer-template" style="background:#d13777;
// text-align:center;border-right:1px solid #171717;
// border-bottom:1px solid #171717;
// padding:5px;"><a href="'. get_site_url().'" target="_blank" title="Kochi Kids" style="color:#fff ;
// text-align:center;
// text-decoration:none !important;">Kochi Kids</a></td>
// </tr>
// </tbody></table>';
// $subject = "Kochi Kids - Account Activated";
// $headers = "MIME-Version: 1.0\r\n";
// $headers .= "Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n";
// $headers .= "From: Kochi Kids <" . $admin_email . "> \r\n";
// $send = wp_mail($old_user_data->user_email, $subject, $body, $headers);
// }
// }
// }
add_filter('acf/update_value/name=user_status', 'my_check_for_change', 10, 3);
function my_check_for_change($value, $user_id, $field) {
$user_id = str_replace('user_', '', $user_id);
$old_value = get_user_meta($user_id, $field['name']);
if ($old_value[0] != $value && $value=='Active') {
$admin_email = get_option("admin_email"); //admin email fetch
$user_data = get_userdata($user_id);
$body_ = "Kochi Kids -Account Activated";
/*use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception; */
//Load Composer's autoloader
/*require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';*/
//date_default_timezone_set('America/Los_Angeles');
$msg_='<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body>';
$msg_.=
'<table width="700px" cellpadding="0" cellspacing="0" style="width:700px;
border-left:1px solid #171717;
border-top:1px solid #171717;
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#000;
margin:0 auto;">
<tbody><tr style="background:#fff;">
<td colspan="2" style="padding:0px !important;border-right:1px solid #171717;
border-bottom:0px solid #171717;
">
<a href="'. get_site_url().'" title="Kochi Kids" style="font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#000;
text-decoration:underline;">
<img src="'.get_stylesheet_directory_uri().'/img/mail-template.jpg" alt="Kochi Kids"></a>
</td>
</tr>
<tr>
<td colspan="2" style="border-right:1px solid #171717;
border-bottom:1px solid #171717;
padding:5px;">
Hi,
<br>
<br>
Thank You,Your account is Activated.<br>
<br> <br>
</td>
</tr> <tr>
<td colspan="2" class="footer-template" style="background:#d13777;
text-align:center;border-right:1px solid #171717;
border-bottom:1px solid #171717;
padding:5px;"><a href="'. get_site_url().'" target="_blank" title="Kochi Kids" style="color:#fff ;
text-align:center;
text-decoration:none !important;">Kochi Kids</a></td>
</tr>
</tbody></table>';
$msg_ .= '</body></html>';
$subject = "Kochi Kids - Account Activated";
$headers = array('Content-Type: text/html; charset=UTF-8');
// $to = implode(", ", [$agencyEmail,$admin_email]);
wp_mail($user_data->user_email, $subject, $msg_, $headers);
/*$subject = "Kochi Kids - Account Activated";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n";
$headers .= "From: Kochi Kids <" . $admin_email . "> \r\n";
$send = wp_mail($user_data->user_email, $subject, $body, $headers);*/
}
return $value;
}
//---------------- Manage Donation Starts Here -----------------------//
add_action('init', 'cptui_register_donations');
function cptui_register_donations() {
register_post_type('donations', array(
'label' => 'Donations',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'page',
'map_meta_cap' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'donation', 'with_front' => false),
'query_var' => true,
'supports' => array('title'),
'menu_position' => 84,
'labels' => array (
'name' => 'Donation',
'singular_name' => 'Donation',
'menu_name' => 'User Donations',
'all_items' => 'All Donations ',
'add_new' => 'Add New Donation',
'add_new_item' => 'Add New Donation',
'edit' => 'Edit',
'edit_item' => 'Edit Donation',
'new_item' => 'New Donation',
'view' => 'View Donation',
'view_item' => 'View Donation',
'search_items' => 'Search Donation',
'not_found' => 'No Donation Found',
'not_found_in_trash' => 'No Donation Found in Trash',
'parent' => 'Parent Donation'
)
)
);
}
add_action('wp_logout','auto_redirect_after_logout');
function auto_redirect_after_logout(){
wp_safe_redirect( get_permalink(17560) );
exit;
}
add_filter( 'manage_donations_posts_columns', 'smashing_filter_posts_columns' );
function smashing_filter_posts_columns( $columns ) {
$columns = array(
'cb' => $columns['cb'],
'title' => __( 'Title' ),
'user' => __( 'User' ),
'payment_status' => __( 'Payment Status', 'smashing' ),
'date' => __( 'Date' )
);
return $columns;
}
add_action( 'manage_donations_posts_custom_column', 'my_manage_donations_columns', 10, 2 );
function my_manage_donations_columns( $column, $post_id ) {
global $post;
$custom = get_post_custom($post->ID);
switch( $column ) {
case 'user' :
$customfield1 = get_post_custom($post->ID);//Returns a multidimensional array with all custom fields of a particular post or page.
$name1= $customfield1;
if($name1 ['user_name'][0]!=0){
print_r( get_user_by( 'id', $name1 ['user_name'][0] )->display_name);
}
else{
print_r( "Guest User");
}
break;
case 'payment_status' :
$customfield = get_post_custom($post->ID);//Returns a multidimensional array with all custom fields of a particular post or page.
$name= $customfield;
print_r( ucwords($name ['payment_status'][0]));
break;
default :
break;
}
}
add_action('init', 'cptui_register_ourchild');
function cptui_register_ourchild() {
register_post_type('ourchild', array(
'label' => 'Our Children',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'our-child', 'with_front' => false ),
'query_var' => true,
// 'exclude_from_search' => false,
'supports' => array('title', 'editor' ,'thumbnail'),
'labels' => array (
'name' => 'Our Children',
'singular_name' => 'Our Children',
'menu_name' => 'Our Children',
'all_items' => 'All Children',
'add_new' => 'Add New Children',
'add_new_item' => 'Add New Children',
'edit' => 'Edit',
'edit_item' => 'Edit Children',
'new_item' => 'New Children',
'view' => 'View Children',
'view_item' => 'View Children',
'search_items' => 'Search Children',
'not_found' => 'No Children Found',
'not_found_in_trash' => 'No Children Found in Trash',
'parent' => 'Parent Our Children',)
)
);
}
wp_enqueue_script('jquery');
add_filter('wp_mail_content_type', function( $content_type ) {
return 'text/html';
});
function cf7_footer_script(){ ?>
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = window.location.origin+'/thank-you/';
}, false );
</script>
<?php }
add_action('wp_footer', 'cf7_footer_script');
function delete_post_type(){
unregister_post_type( 'donation' );
}
add_action('init','delete_post_type');
?>