__( 'Top Menu', 'cactus' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'comment-form',
'comment-list',
'gallery',
'caption',
) );
// Add theme support for Custom Logo.
add_theme_support( 'custom-logo', array(
'width' => 152,
'height' => 50,
'flex-width' => true,
) );
// Setup the WordPress core custom header feature.
add_theme_support( 'custom-header', array(
'default-image' => '',
'random-default' => false,
'width' => '1920',
'height' => '70',
'flex-height' => true,
'flex-width' => true,
'default-text-color' => '#333333',
'header-text' => true,
'uploads' => true,
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => ''
));
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', array(
'default-color' => 'ffffff',
'default-image' => '',
) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors, and column width.
*/
add_editor_style( array( 'assets/css/editor-style.css' ) );
}
add_action( 'after_setup_theme', 'cactus_setup' );
/**
* Enqueue scripts and styles.
*/
function cactus_scripts() {
global $cactus_options;
$cactus_options = get_option('cactus_options');
wp_enqueue_style( 'bootstrap', get_template_directory_uri() .'/assets/plugins/bootstrap/css/bootstrap.css', false, '', false );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() .'/assets/plugins/font-awesome/css/font-awesome.min.css', false, '', false );
// Theme stylesheet.
wp_enqueue_style( 'cactus-style', get_stylesheet_uri() );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/plugins/bootstrap/js/bootstrap.js' , array( 'jquery' ), null, true);
wp_enqueue_script( 'cactus-main', get_template_directory_uri() . '/assets/js/cactus.js' , array( 'jquery' ), null, true);
wp_enqueue_script( 'cactus-main', get_template_directory_uri() . '/assets/plugins/respond.min.js' , array( 'jquery' ), null, true);
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
$custom_css = '';
$header_text_color = get_header_textcolor();
if ( 'blank' != $header_text_color ) :
$custom_css .= ".site-name,
.site-tagline {
color: #".esc_attr( $header_text_color )." !important;
}\r\n";
else:
$custom_css .= ".site-name,
.site-tagline {
display: none;
}\r\n";
endif;
wp_add_inline_style( 'cactus-style', wp_filter_nohtml_kses($custom_css) );
}
add_action( 'wp_enqueue_scripts', 'cactus_scripts' );
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function cactus_posted_on() {
// Get the author name; wrap it in a link.
$byline = sprintf(
/* translators: %s: post author */
__( 'by %s', 'cactus' ),
' ' . get_the_author() . ''
);
// Finally, let's write all of this to the page.
echo '' . cactus_time_link() . ' | ' . $byline . '';
}
/**
* Gets a nicely formatted string for the published date.
*/
function cactus_time_link() {
$time_string = '';
$time_string = sprintf( $time_string,
get_the_date( DATE_W3C ),
get_the_date(),
get_the_modified_date( DATE_W3C ),
get_the_modified_date()
);
// Wrap the time string in a link, and preface it with 'Posted on'.
return sprintf(
/* translators: %s: post date */
__( 'Posted on %s ', 'cactus' ),
'' . $time_string . ''
);
}
/**
* Returns an accessibility-friendly link to edit a post or page.
*/
function cactus_edit_link() {
$link = edit_post_link(
sprintf(
/* translators: %s: Name of current post */
__( 'Edit "%s"', 'cactus' ),
get_the_title()
),
'',
''
);
return $link;
}
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function cactus_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'cactus' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar.', 'cactus' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer 1', 'cactus' ),
'id' => 'footer-1',
'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 2', 'cactus' ),
'id' => 'footer-2',
'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 3', 'cactus' ),
'id' => 'footer-3',
'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer 4', 'cactus' ),
'id' => 'footer-4',
'description' => __( 'Add widgets here to appear in your footer.', 'cactus' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'cactus_widgets_init' );
/**
* Custom comments list
*/
function cactus_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>
id="comment-">
comment_approved == '0') : ?>
';
$after = '';
if ( !is_home() && !is_front_page() || is_paged() ) {
echo '';
global $post;
$homeLink = home_url();
echo '
' . __( 'Home' , 'cactus' ) . ' ' . $delimiter . ' ';
if ( is_category() ) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category($thisCat);
$parentCat = get_category($thisCat->parent);
if ($thisCat->parent != 0){
$cat_code = get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' ');
echo $cat_code = str_replace ('
' . get_the_time('Y') . ' ' . $delimiter . ' ';
echo '
' . get_the_time('F') . ' ' . $delimiter . ' ';
echo $before . get_the_time('d') . $after;
} elseif ( is_month() ) {
echo '
' . get_the_time('Y') . ' ' . $delimiter . ' ';
echo $before . get_the_time('F') . $after;
} elseif ( is_year() ) {
echo $before . get_the_time('Y') . $after;
} elseif ( is_single() && !is_attachment() ) {
if ( get_post_type() != 'post' ) {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '
' . $post_type->labels->singular_name . ' ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} else {
$cat = get_the_category(); $cat = $cat[0];
$cat_code = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo $cat_code = str_replace ('
labels->singular_name . $after;
} elseif ( is_attachment() ) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID); $cat = $cat[0];
echo '' . $parent->post_title . ' ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} elseif ( is_page() && !$post->post_parent ) {
echo $before . get_the_title() . $after;
} elseif ( is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '
' . get_the_title($page->ID) . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} elseif ( is_search() ) {
echo $before ;
printf( __( 'Search Results for: %s', 'cactus' ), get_search_query() );
echo $after;
} elseif ( is_tag() ) {
echo $before ;
printf( __( 'Tag Archives: %s', 'cactus' ), single_tag_title( '', false ) );
echo $after;
} elseif ( is_author() ) {
global $author;
$userdata = get_userdata($author);
echo $before ;
printf( __( 'Author Archives: %s', 'cactus' ), $userdata->display_name );
echo $after;
} elseif ( is_404() ) {
echo $before;
_e( 'Not Found', 'cactus' );
echo $after;
}
if ( get_query_var('paged') ) { // ·ÖÒ³
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() )
echo sprintf( __( '( Page %s )', 'cactus' ), get_query_var('paged') );
}
echo '
';
}
}
/**
* Theme options
*/
function cactus_customize_register( $wp_customize ) {
$wp_customize->add_section( 'cactus_footer' , array(
'title' => __( 'Footer Options', 'cactus' ),
'priority' => 30,
) );
// Display Footer Widgets Area
$wp_customize->add_setting( 'cactus_options[enable_footer_widgets]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'absint'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'enable_footer_widgets',
array(
'label' => __( 'Display Footer Widgets Area', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[enable_footer_widgets]',
'type' => 'checkbox',
)
)
);
// Footer Logo
$wp_customize->add_setting( 'cactus_options[footer_logo]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_url_raw'
) );
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'footer_logo',
array(
'label' => __( 'Upload Footer Logo', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_logo]',
'context' => ''
)
)
);
$wp_customize->selective_refresh->add_partial( 'footer_logo_selective', array(
'selector' => '.cactus-footer-logo',
'settings' => array( 'cactus_options[footer_logo]' ),
'render_callback' => '',
) );
// Display Footer Social Icons
$wp_customize->add_setting( 'cactus_options[enable_footer_icons]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'absint'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'enable_footer_icons',
array(
'label' => __( 'Display Footer Social Icons (Font Awesome Icon, e.g. fa-facebook)', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[enable_footer_icons]',
'type' => 'checkbox',
)
)
);
// Social Icons
$wp_customize->add_setting( 'cactus_options[footer_icon_1]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_1',
array(
'label' => __( 'Footer Social Icon 1', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_1]',
'type' => 'text',
)
)
);
$wp_customize->add_setting( 'cactus_options[footer_icon_link_1]', array(
'default' => '#',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_url_raw'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_link_1',
array(
'label' => __( 'Footer Social Icon Link 1', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_link_1]',
'type' => 'text',
)
)
);
$wp_customize->add_setting( 'cactus_options[footer_icon_2]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_2',
array(
'label' => __( 'Footer Social Icon 2', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_2]',
'type' => 'text',
)
)
);
$wp_customize->add_setting( 'cactus_options[footer_icon_link_2]', array(
'default' => '#',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_url_raw'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_link_2',
array(
'label' => __( 'Footer Social Icon Link 2', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_link_2]',
'type' => 'text',
)
)
);
$wp_customize->add_setting( 'cactus_options[footer_icon_3]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_3',
array(
'label' => __( 'Footer Social Icon 3', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_3]',
'type' => 'text',
)
)
);
$wp_customize->add_setting( 'cactus_options[footer_icon_link_3]', array(
'default' => '#',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_url_raw'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_link_3',
array(
'label' => __( 'Footer Social Icon Link 3', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_link_3]',
'type' => 'text',
)
)
);
$wp_customize->add_setting( 'cactus_options[footer_icon_4]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_4',
array(
'label' => __( 'Footer Social Icon 4', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_4]',
'type' => 'text',
)
)
);
$wp_customize->add_setting( 'cactus_options[footer_icon_link_4]', array(
'default' => '#',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_url_raw'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_link_4',
array(
'label' => __( 'Footer Social Icon Link 4', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_link_4]',
'type' => 'text',
)
)
);
$wp_customize->add_setting( 'cactus_options[footer_icon_5]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_5',
array(
'label' => __( 'Footer Social Icon 5', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_5]',
'type' => 'text',
)
)
);
$wp_customize->add_setting( 'cactus_options[footer_icon_link_5]', array(
'default' => '#',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'refresh',
'sanitize_callback' => 'esc_url_raw'
) );
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_icon_link_5',
array(
'label' => __( 'Footer Social Icon Link 5', 'cactus' ),
'section' => 'cactus_footer',
'settings' => 'cactus_options[footer_icon_link_5]',
'type' => 'text',
)
)
);
$wp_customize->selective_refresh->add_partial( 'footer_sns_selective', array(
'selector' => '.cactus-footer-sns',
'settings' => array( 'cactus_options[footer_icon_1]' ),
'render_callback' => '',
) );
}
add_action( 'customize_register', 'cactus_customize_register' );