2019-03-08 15:36:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
// Enqueue styles - get parent theme styles first.
|
|
|
|
function my_theme_enqueue_styles() {
|
|
|
|
|
|
|
|
$parent_style = 'parent-style'; // This is 'twentynineteen-style' for the Twenty Nineteen theme.
|
|
|
|
|
|
|
|
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
|
|
|
|
wp_enqueue_style( 'child-style',
|
|
|
|
get_stylesheet_directory_uri() . '/style.css',
|
|
|
|
array( $parent_style ),
|
|
|
|
wp_get_theme()->get('Version')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
|
|
|
|
|
|
|
|
|
|
|
|
// theme mods
|
|
|
|
// set_theme_mod( 'page_layout', 'one-column' );
|
|
|
|
|
|
|
|
|
2019-03-08 15:36:51 +00:00
|
|
|
|
|
|
|
// Allow front end acf form edits
|
|
|
|
// https://usersinsights.com/acf-user-profile/
|
|
|
|
function my_acf_user_form_func( $atts ) {
|
|
|
|
|
|
|
|
$a = shortcode_atts( array(
|
|
|
|
'field_group' => ''
|
|
|
|
), $atts );
|
|
|
|
|
|
|
|
$uid = get_current_user_id();
|
|
|
|
|
|
|
|
if ( ! empty ( $a['field_group'] ) && ! empty ( $uid ) ) {
|
|
|
|
$options = array(
|
|
|
|
'post_id' => 'user_'.$uid,
|
|
|
|
'field_groups' => array( intval( $a['field_group'] ) ),
|
|
|
|
'return' => add_query_arg( 'updated', 'true', get_permalink() )
|
|
|
|
);
|
|
|
|
|
|
|
|
ob_start();
|
|
|
|
|
|
|
|
acf_form( $options );
|
|
|
|
$form = ob_get_contents();
|
|
|
|
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $form;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_shortcode( 'my_acf_user_form', 'my_acf_user_form_func' );
|
|
|
|
|
|
|
|
|
|
|
|
//adding AFC form head
|
2019-03-11 17:31:32 +00:00
|
|
|
function wasmo_add_acf_form_head(){
|
2019-03-08 15:36:51 +00:00
|
|
|
global $post;
|
|
|
|
|
|
|
|
if ( !empty($post) && has_shortcode( $post->post_content, 'my_acf_user_form' ) ) {
|
|
|
|
acf_form_head();
|
|
|
|
}
|
|
|
|
}
|
2019-03-11 17:31:32 +00:00
|
|
|
add_action( 'wp_head', 'wasmo_add_acf_form_head', 7 );
|
|
|
|
|
|
|
|
|
|
|
|
// hide admin bar for non admin users
|
|
|
|
add_action( 'set_current_user', 'wasmo_hide_admin_bar' );
|
|
|
|
function wasmo_hide_admin_bar() {
|
2019-03-12 13:36:03 +00:00
|
|
|
if ( !current_user_can( 'publish_posts' ) ) {
|
2019-03-11 17:31:32 +00:00
|
|
|
show_admin_bar( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-12 13:36:03 +00:00
|
|
|
|
|
|
|
function cptui_register_my_taxes() {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Taxonomy: Questions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
$labels = array(
|
|
|
|
"name" => __( "Questions", "wasmo" ),
|
|
|
|
"singular_name" => __( "Question", "wasmo" ),
|
|
|
|
);
|
|
|
|
|
|
|
|
$args = array(
|
|
|
|
"label" => __( "Questions", "wasmo" ),
|
|
|
|
"labels" => $labels,
|
|
|
|
"public" => true,
|
|
|
|
"publicly_queryable" => true,
|
|
|
|
"hierarchical" => false,
|
|
|
|
"show_ui" => true,
|
|
|
|
"show_in_menu" => true,
|
|
|
|
"show_in_nav_menus" => true,
|
|
|
|
"query_var" => true,
|
|
|
|
"rewrite" => array( 'slug' => 'question', 'with_front' => true, ),
|
|
|
|
"show_admin_column" => true,
|
|
|
|
"show_in_rest" => true,
|
|
|
|
"rest_base" => "question",
|
|
|
|
"rest_controller_class" => "WP_REST_Terms_Controller",
|
|
|
|
"show_in_quick_edit" => true,
|
|
|
|
"capabilities" =>
|
|
|
|
array(
|
|
|
|
'manage_terms' => 'edit_posts',
|
|
|
|
'edit_terms' => 'edit_posts',
|
|
|
|
'delete_terms' => 'edit_posts',
|
|
|
|
'assign_terms' => 'edit_posts'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
register_taxonomy( "question", array( "post" ), $args );
|
|
|
|
}
|
|
|
|
add_action( 'init', 'cptui_register_my_taxes' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function wasmo_widgets_init() {
|
|
|
|
|
|
|
|
register_sidebar(
|
|
|
|
array(
|
|
|
|
'name' => __( 'Sidebar', 'twentynineteen' ),
|
|
|
|
'id' => 'sidebar',
|
|
|
|
'description' => __( 'Add widgets here to appear in your sidebar.', 'twentynineteen' ),
|
|
|
|
'before_widget' => '<section id="%1$s" class="widget %2$s">',
|
|
|
|
'after_widget' => '</section>',
|
|
|
|
'before_title' => '<h2 class="widget-title">',
|
|
|
|
'after_title' => '</h2>',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
add_action( 'widgets_init', 'wasmo_widgets_init' );
|
|
|
|
|
|
|
|
if ( ! function_exists( 'wasmo_setup' ) ) :
|
|
|
|
function wasmo_setup() {
|
|
|
|
register_nav_menus(
|
|
|
|
array(
|
|
|
|
'utility' => __( 'Utility Menu', 'twentynineteen' ),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
add_action( 'after_setup_theme', 'wasmo_setup' );
|
2019-03-11 17:31:32 +00:00
|
|
|
|
2019-03-12 14:39:56 +00:00
|
|
|
function wasmo_loginout_menu_link( $items, $args ) {
|
|
|
|
if ($args->theme_location == 'utility') {
|
|
|
|
if (is_user_logged_in()) {
|
|
|
|
$items .= '<li><a href="'. wp_logout_url() .'">'. __("Log Out") .'</a></li>';
|
|
|
|
} else {
|
|
|
|
$items .= '<li><a href="/login">'. __("Log In") .'</a></li>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $items;
|
|
|
|
}
|
|
|
|
add_filter( 'wp_nav_menu_items', 'wasmo_loginout_menu_link', 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
function wasmo_login_redirect_page() {
|
|
|
|
return '/edit';
|
|
|
|
}
|
|
|
|
add_filter('login_redirect', 'wasmo_login_redirect_page');
|
|
|
|
|
|
|
|
function wasmo_logout_redirect_page() {
|
|
|
|
return '/login';
|
|
|
|
}
|
|
|
|
add_filter('logout_redirect', 'wasmo_logout_redirect_page');
|
|
|
|
|
|
|
|
|
2019-03-11 22:31:02 +00:00
|
|
|
function my_acf_init() {
|
|
|
|
acf_update_setting('google_api_key', 'AIzaSyAF3HYVew1ZS_9i0mY1wymX1Hs885AJtIw');
|
|
|
|
}
|
|
|
|
|
|
|
|
add_action('acf/init', 'my_acf_init');
|
2019-03-08 15:36:51 +00:00
|
|
|
|
2019-03-08 15:36:23 +00:00
|
|
|
?>
|