php apuc,quest-theme/functions.php at master · apuc/quest-theme · GitHub

define('TM_DIR', get_template_directory(__FILE__));

define('TM_URL', get_template_directory_uri(__FILE__));

require_once TM_DIR . '/lib/Parser.php';

function add_style(){

/*wp_enqueue_style( 'my-bootstrap-extension', get_template_directory_uri() . '/css/bootstrap.css', array(), '1');*/

wp_enqueue_style( 'fancybox', get_template_directory_uri() . '/css/jquery.fancybox.css', array(), '1');

wp_enqueue_style( 'my-styles', get_template_directory_uri() . '/css/style.css', array('fancybox'), '1');

/* wp_enqueue_style( 'my-sass', get_template_directory_uri() . '/sass/style.css', array('my-bootstrap-extension'), '1');

wp_enqueue_style( 'fotorama', get_template_directory_uri() . '/css/fotorama.css', array('my-bootstrap-extension'), '1');*/

}

function add_script(){

wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/jquery-2.1.3.min.js', array(), '1');

wp_enqueue_script( 'jq', 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', array(), '1');

wp_enqueue_script( 'fancybox', get_template_directory_uri() . '/js/jquery.fancybox.js', array('jq'), '1');

wp_enqueue_script( 'fancybox-pack', get_template_directory_uri() . '/js/jquery.fancybox.pack.js', array('fancybox'), '1');

wp_enqueue_script( 'my-script', get_template_directory_uri() . '/js/script.js', array('fancybox-pack'), '1');

wp_localize_script( 'jquery', 'myajax',

array(

'url' => admin_url('admin-ajax.php'),

'nonce' => wp_create_nonce('myajax-nonce')

));

}

function add_admin_script(){

}

add_action('admin_enqueue_scripts', 'add_admin_script');

add_action( 'wp_enqueue_scripts', 'add_style' );

add_action( 'wp_enqueue_scripts', 'add_script' );

function prn($content) {

echo '

';

print_r ( $content );

echo '

';

}

add_action('customize_register', function($customizer){

/*Меню настройки главной страницы*/

$customizer->add_section(

'contacts_section',

array(

'title' => 'Настройки логотипа и номера телефона',

'description' => 'Контакты',

'priority' => 35,

)

);

$customizer->add_setting('img-logo');

$customizer->add_control(

new WP_Customize_Image_Control(

$customizer,

'img-logo',

array(

'label' => 'Логотипа',

'section' => 'contacts_section',

'settings' => 'img-logo'

)

)

);

$customizer->add_setting(

'phone_textbox',

array('default' => '+7 (985) 777-26-25')

);

$customizer->add_control(

'phone_textbox',

array(

'label' => 'Телефон',

'section' => 'contacts_section',

'type' => 'text',

)

);

/*Настройка 2-го сегмента*/

$customizer->add_section(

'second_segment',

array(

'title' => 'Настройка 2-го сегмента',

'description' => 'Контакты',

'priority' => 35,

)

);

$customizer->add_setting(

'h1_first',

array('default' => 'Профессиональный сценарий')

);

$customizer->add_control(

'h1_first',

array(

'label' => 'Первая строка',

'section' => 'second_segment',

'type' => 'text',

)

);

$customizer->add_setting(

'h1_second',

array('default' => 'для Вашего квеста в реальности!')

);

$customizer->add_control(

'h1_second',

array(

'label' => 'Вторая строка',

'section' => 'second_segment',

'type' => 'text',

)

);

$customizer->add_setting(

'p_first',

array('default' => 'всего за 10 дней!')

);

$customizer->add_control(

'p_first',

array(

'label' => 'Маленький текст',

'section' => 'second_segment',

'type' => 'text',

)

);

$customizer->add_setting('img-back-second-segment');

$customizer->add_control(

new WP_Customize_Image_Control(

$customizer,

'img-back-second-segment',

array(

'label' => 'Логотипа',

'section' => 'second_segment',

'settings' => 'img-back-second-segment'

)

)

);

/*Настройка цен*/

$customizer->add_section(

'price',

array(

'title' => 'Настройка цен',

'description' => 'Цены',

'priority' => 35,

)

);

$customizer->add_setting(

'scenario',

array('default' => '75 000')

);

$customizer->add_control(

'scenario',

array(

'label' => 'Сценарий для квеста',

'section' => 'price',

'type' => 'text',

)

);

$customizer->add_setting(

'music',

array('default' => '24 000')

);

$customizer->add_control(

'music',

array(

'label' => 'Музыкальное сопровождение',

'section' => 'price',

'type' => 'text',

)

);

$customizer->add_setting(

'all_price',

array('default' => '99 000')

);

$customizer->add_control(

'all_price',

array(

'label' => 'Всего',

'section' => 'price',

'type' => 'text',

)

);

$customizer->add_setting(

'all_price_sale',

array('default' => '79 000')

);

$customizer->add_control(

'all_price_sale',

array(

'label' => 'Всего со скидкой',

'section' => 'price',

'type' => 'text',

)

);

$customizer->add_setting(

'price_sale',

array('default' => '20 000')

);

$customizer->add_control(

'price_sale',

array(

'label' => 'Скидка при совместном заказе',

'section' => 'price',

'type' => 'text',

)

);

/*Настройка данных в футере*/

$customizer->add_section(

'footer_info',

array(

'title' => 'Настройка данных в футере',

'description' => 'Данные',

'priority' => 35,

)

);

$customizer->add_setting(

'inn',

array('default' => 'ИП Постнова М.П., ИНН 301726210632, ОГРНИП 309301620100039, БИК 041806835, Р/с 40802810310000040955')

);

$customizer->add_control(

'inn',

array(

'label' => 'Регистрационные данные',

'section' => 'footer_info',

'type' => 'text',

)

);

$customizer->add_setting(

'address',

array('default' => 'г. Астрахань, ул. Кирова 55а, офис 414‏')

);

$customizer->add_control(

'address',

array(

'label' => 'Адрес',

'section' => 'footer_info',

'type' => 'text',

)

);

});

function my_pagenavi() {

global $wp_query;

$big = 999999999; // уникальное число для замены

$args = array(

'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) )

,'format' => ''

,'current' => max( 1, get_query_var('paged') )

,'total' => $wp_query->max_num_pages

);

$result = paginate_links( $args );

// удаляем добавку к пагинации для первой страницы

$result = str_replace( '/page/1/', '', $result );

echo $result;

}

function excerpt_readmore($more) {

return '... ' . 'Читать далее' . '';

}

add_filter('excerpt_more', 'excerpt_readmore');

if ( function_exists( 'add_theme_support' ) )

add_theme_support( 'post-thumbnails' );

// Custom page types

add_action('init', 'my_custom_init');

function my_custom_init()

{

//scenario

$labels = array(

'name' => 'Сценарии', // Основное название типа записи

'singular_name' => 'Сценарий', // отдельное название записи типа Book

'add_new' => 'Добавить Сценарий',

'add_new_item' => 'Добавить новый Сценарий',

'edit_item' => 'Редактировать Сценарий',

'new_item' => 'Новый Сценарий',

'view_item' => 'Посмотреть Сценарий',

'search_items' => 'Найти Сценарий',

'not_found' => 'Сценариев не найдено',

'menu_name' => 'Сценарии'

);

$args = array(

'labels' => $labels,

'public' => true,

'publicly_queryable' => true,

'show_ui' => true,

'show_in_menu' => true,

'query_var' => true,

'rewrite' => true,

'capability_type' => 'post',

'has_archive' => true,

'hierarchical' => false,

'menu_position' => null,

'supports' => array('title', 'editor', 'thumbnail')

);

register_post_type('scenario', $args);

//Our team

$labels = array(

'name' => 'Наша команда', // Основное название типа записи

'singular_name' => 'Наша команда', // отдельное название записи типа Book

'add_new' => 'Добавить человека',

'add_new_item' => 'Добавить нового человека',

'edit_item' => 'Редактировать человека',

'new_item' => 'Новый человек',

'view_item' => 'Посмотреть человека',

'search_items' => 'Найти человека',

'not_found' => 'Членов команды не найдено',

'menu_name' => 'Наша команда'

);

$args = array(

'labels' => $labels,

'public' => true,

'publicly_queryable' => true,

'show_ui' => true,

'show_in_menu' => true,

'query_var' => true,

'rewrite' => true,

'capability_type' => 'post',

'has_archive' => true,

'hierarchical' => false,

'menu_position' => null,

'supports' => array('title', 'editor', 'thumbnail')

);

register_post_type('our_team', $args);

//Examples

$labels = array(

'name' => 'Примеры из сценариев', // Основное название типа записи

'singular_name' => 'Примеры из сценариев', // отдельное название записи типа Book

'add_new' => 'Добавить пример из сценария',

'add_new_item' => 'Добавить новый пример из сценария',

'edit_item' => 'Редактировать пример из сценария',

'new_item' => 'Новый пример из сценария',

'view_item' => 'Посмотреть пример из сценария',

'search_items' => 'Найти пример из сценария',

'not_found' => 'Пример из сценариев не найдено',

'menu_name' => 'Примеры из сценариев'

);

$args = array(

'labels' => $labels,

'public' => true,

'publicly_queryable' => true,

'show_ui' => true,

'show_in_menu' => true,

'query_var' => true,

'rewrite' => true,

'capability_type' => 'post',

'has_archive' => true,

'hierarchical' => false,

'menu_position' => null,

'supports' => array('title', 'thumbnail')

);

register_post_type('examples', $args);

}

// подключаем функцию активации мета блока в сценарии(my_extra_fields)

add_action('add_meta_boxes', 'my_extra_fields', 1);

function my_extra_fields() {

add_meta_box( 'extra_fields', 'Дополнительные поля', 'extra_fields_box_func', 'scenario', 'normal', 'high' );

}

// код блока

function extra_fields_box_func( $post ){

?>

Город

New

$checkbox_value = get_post_meta($post->ID, "meta-box-checkbox", true);

if($checkbox_value == "")

{

?>

}

else if($checkbox_value == "true")

{

?>

}

?>

}

// включаем обновление полей при сохранении

add_action('save_post', 'my_extra_fields_update', 0);

/* Сохраняем данные, при сохранении поста */

function my_extra_fields_update( $post_id ){

if ( !wp_verify_nonce($_POST['extra_fields_nonce'], __FILE__) ) return false; // проверка

if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return false; // если это автосохранение

if ( !current_user_can('edit_post', $post_id) ) return false; // если юзер не имеет право редактировать запись

$chk = isset( $_POST['my_meta_box_check'] ) && $_POST['my_meta_box_select'] ? 'on' : 'off';

if( !isset($_POST['extra']) ) return false;

$meta_box_checkbox_value = "";

if(isset($_POST["meta-box-checkbox"]))

{

$meta_box_checkbox_value = $_POST["meta-box-checkbox"];

}

update_post_meta($post_id, "meta-box-checkbox", $meta_box_checkbox_value);

// Все ОК! Теперь, нужно сохранить/удалить данные

$_POST['extra'] = array_map('trim', $_POST['extra']);

foreach( $_POST['extra'] as $key=>$value ){

if( empty($value) ){

delete_post_meta($post_id, $key); // удаляем поле если значение пустое

continue;

}

update_post_meta($post_id, $key, $value); // add_post_meta() работает автоматически

}

return $post_id;

}

add_action( 'wp_ajax_nopriv_myajax-submit', 'myajax_submit' );

add_action( 'wp_ajax_myajax-submit', 'myajax_submit' );

function myajax_submit() {

// $nonce = $_POST['nonce'];

// // проверяем nonce код, если проверка не пройдена прерываем обработку

// if ( !wp_verify_nonce( $nonce, 'myajax-nonce' ) )

// die ( 'Stop!')

// обрабатываем данные и возвращаем

add_filter( 'wp_mail_content_type', 'set_html_content_type' );

$admin_email=get_option('admin_email');

$form_name= $_POST['title'];

$str = 'Имя:'.$_POST['name'].'
Телефон:'.$_POST['phone'].'
Email:'.$_POST['email'].'
Сообщение:'.$_POST['comment'];

mail($admin_email, $form_name, $str , "Content-type: text/html; charset=UTF-8\r\n");

// wp_mail( $admin_email, $form_name, 'Имя:'.$_POST['name'].'
Телефон:'.$_POST['phone'].'
Email:'.$_POST['email'].'
Сообщение:'.$_POST['comment'], "Content-type: text/html; charset=UTF-8\r\n" );

// Сбросим content-type, чтобы избежать возможного конфликта

remove_filter( 'wp_mail_content_type', 'set_html_content_type' );

function set_html_content_type() {

return 'text/html';

}

// echo $_POST['comment'];

// echo $_POST['email'];

// echo $_POST['phone'];

// echo get_option('admin_email');

// Не забываем выходить

exit;

}

register_nav_menus(array(

'header_menu' => 'Меню',

));

购物商城项目采用PHP+mysql有以及html+css jq以及layer.js datatables bootstorap等插件等开发,采用了MVC模式,建立一个完善的电商系统,通过不同用户的不同需求,进行相应的调配和处理,提高对购买用户进行配置….zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值