/** * * @package Kopa * @subpackage Core * @author thethangtran <*****@*****.**> * @since 1.0.0 * */ function kopa_options_social_links() { $groups['social-links'] = array('icon' => '', 'title' => __('Social Links', kopa_get_domain()), 'fields' => array()); $social_icons = KopaInit::get_social_icons(); if ($social_icons) { foreach ($social_icons as $slug => $info) { $groups['social-links']['fields'][] = array('type' => 'text', 'id' => "social_link_{$slug}", 'name' => "social_link_{$slug}", 'label' => sprintf('%s <i class="%s kps-iconmoon pull-right" style="color:%s"></i>', $info['title'], $info['icon'], $info['color']), 'help' => isset($info['help']) ? $info['help'] : '', 'default' => ''); } } return apply_filters('kopa_options_social_links', $groups); }
/** * * * @package Kopa * @subpackage Core * @author thethangtran <*****@*****.**> * @since 1.0.0 * */ public static function get_form($template_hierarchy, $setting = array(), $name = '') { $kopa_sidebar_position = KopaInit::get_positions(); $kopa_layout = KopaInit::get_layouts(); $kopa_template_hierarchy = KopaInit::get_template_hierarchy(); $sidebars = get_option(KOPA_OPT_PREFIX . 'sidebars'); $obj = $kopa_template_hierarchy[$template_hierarchy]; $html = '<div class="layout-manage-wrap">'; $html .= '<div class="row clearfix">'; #FORM $html .= '<div class="col-md-5">'; #CBO Layouts $cbo_layout_opts = array(); foreach ($obj['layouts'] as $tmp_layout_slug) { $tmp_layout = $kopa_layout[$tmp_layout_slug]; $cbo_layout_opts[$tmp_layout['slug']] = $tmp_layout['title']; } $tmp_cbo = array('type' => 'select', 'id' => sprintf("cbo_layout_%s", $name), 'name' => sprintf("%s[layout_slug]", $name), 'label' => __('Select the layout', kopa_get_domain()), 'options' => $cbo_layout_opts, 'wrap_begin' => '<div class="row-layout-wrap row clearfix">', 'wrap_end' => '</div>', 'control_begin' => '<div class="col-md-12">', 'control_end' => '</div>', 'label_begin' => '<div class="col-layout-title col-md-12">', 'label_end' => '</div>', 'classes' => array('cbo_layout'), 'value' => $setting['layout_slug'], 'attributes' => array('onchange' => 'KopaLayout.onChange(event, jQuery(this));')); $html .= KopaControl::get_html($tmp_cbo); #END-CBO Layouts foreach ($obj['layouts'] as $tmp_layout_slug) { $tmp_layout = $kopa_layout[$tmp_layout_slug]; $classes = array('row-sidebars-wrap', 'row', 'clearfix'); $classes[] = $setting['layout_slug'] == $tmp_layout['slug'] ? 'row-sidebars-active' : 'row-sidebars-deactive'; $classes[] = "row-sidebars-for-layout-{$tmp_layout['slug']}"; $html .= sprintf('<div class="%s">', implode(' ', $classes)); $html .= '<div class="col-md-12">'; $tmp_positions = $tmp_layout['positions']; for ($i = 0; $i < count($tmp_positions); $i++) { $tmp_position = $tmp_positions[$i]; $tmp_cbo = array('type' => 'select', 'id' => sprintf("cbo_%s_%s", $name, $tmp_position), 'name' => sprintf("%s[sidebars][%s][]", $name, $tmp_layout_slug), 'options' => $sidebars, 'label' => $kopa_sidebar_position[$tmp_position]['title'], 'wrap_begin' => '<div class="row-sidebar-wrap row clearfix">', 'wrap_end' => '</div>', 'control_begin' => '<div class="col-xs-7">', 'control_end' => '</div>', 'label_begin' => '<div class="col-xs-5 col-sidebar-title">', 'label_end' => '</div>', 'classes' => array('cbo_sidebar'), 'value' => $setting['sidebars'][$tmp_layout_slug][$i]); $html .= KopaControl::get_html($tmp_cbo); } $html .= '</div>'; $html .= '</div>'; } $html .= '</div>'; #END-FORM #THUMBNAIL $html .= '<div class="col-md-7 col-layout-thumb">'; foreach ($obj['layouts'] as $tmp_layout_slug) { $classes = array('img-responsive'); $classes[] = $setting['layout_slug'] == $tmp_layout_slug ? 'layout-thumb-active' : 'layout-thumb-deactive'; $classes[] = "thumb-for-layout-{$tmp_layout_slug}"; $html .= sprintf('<img src="%s" class="%s">', get_template_directory_uri() . "/library/images/layout/{$tmp_layout_slug}.png", implode(' ', $classes)); } $html .= '</div>'; #END-THUMBNAIL $html .= '</div>'; $html .= '</div>'; return $html; }
/** * * * @package Kopa * @subpackage Core * @author thethangtran <*****@*****.**> * @since 1.0.0 * */ public static function get_image_src($image, $size = NULL, $width = NULL, $height = NULL, $crop = true) { $src = NULL; if ($size) { $size = self::detect_image_size($size); } if (!empty($image)) { if (empty($width) && empty($height) && !empty($size)) { $sizes = KopaInit::get_image_sizes(); if (isset($sizes[$size])) { $width = $sizes[$size]['width']; $height = $sizes[$size]['height']; $crop = $sizes[$size]['crop']; } } $src = bfi_thumb($image, array('width' => $width, 'height' => $height, 'crop' => $crop)); } return apply_filters('kopa_image_get_image_src', $src); }
/** * @package Kopa * @subpackage Core * @author thethangtran <*****@*****.**> * @since 1.0.0 */ function kopa_save_layout_setting() { check_ajax_referer('kopa_save_layout_setting', 'ajax_nonce'); $kopa_template_hierarchy = KopaInit::get_template_hierarchy(); $data = $_POST; $new_data = array(); foreach ($kopa_template_hierarchy as $slug => $info) { $new_data[$slug] = $data[$slug]; } update_option(KOPA_OPT_PREFIX . 'layout_settings', $new_data); exit; }
<?php /** * * @package Kopa * @subpackage Core * @author thethangtran <*****@*****.**> * @since 1.0.0 * */ $kopa_template_hierarchy = KopaInit::get_template_hierarchy(); $tmp_kopaSettings = get_option(KOPA_OPT_PREFIX . 'layout_settings'); ?> <img id="kopa-loading-gif" src="<?php echo get_template_directory_uri() . '/library/images/loading.gif'; ?> "> <div id="kopa-cpanel-wrapper" class="clearfix"> <div class="col-left pull-left"> <ul class="kopa-cpanel-nav"> <?php $is_first = true; foreach ($kopa_template_hierarchy as $slug => $tab) { if ($is_first) { printf('<li><a class="kopa-tab-link active" href="#tab-%s"><i class="%s"></i> <span>%s</span></a></li>', $slug, $tab['icon'], $tab['title']); $is_first = false; } else { printf('<li><a class="kopa-tab-link" href="#tab-%s"><i class="%s"></i><span>%s</span></a></li>', $slug, $tab['icon'], $tab['title']); } ?>
<?php $tmp_kopaSettings = get_option(KOPA_OPT_PREFIX . 'layout_settings'); $post = new KopaPosttype('Post', 'post', '', array(), array(), array(), array(), array('styles' => array(KOPA_OPT_PREFIX . 'bootstrap', KOPA_OPT_PREFIX . 'ui', KOPA_OPT_PREFIX . 'layout-manager'), 'scripts' => array(KOPA_OPT_PREFIX . 'bootstrap', KOPA_OPT_PREFIX . 'shortcodes', KOPA_OPT_PREFIX . 'ui', KOPA_OPT_PREFIX . 'layout-manager', KOPA_OPT_PREFIX . 'metabox'))); /** * Add metaboxes "Layout & Sidebar Options" for POST */ $metaboxes['fields'] = array(array('type' => 'checkbox', 'id' => KOPA_OPT_PREFIX . 'is_use_custom_layout', 'name' => KOPA_OPT_PREFIX . 'is_use_custom_layout', 'default' => 'false', 'classes' => array('ckb_is_use_custom_layout_toggle'), 'label' => __('Is use custom layout for this post', kopa_get_domain()), 'is_append_label_before_control' => false, 'help' => NULL, 'attributes' => array('onchange' => 'KopaLayout.isUseCustomLayoutToggle(event, jQuery(this));')), array('type' => 'layout', 'id' => KOPA_OPT_PREFIX . 'layout', 'name' => KOPA_OPT_PREFIX . 'layout', 'default' => $tmp_kopaSettings['post'], 'template_hierarchy' => 'post')); $post->add_meta_box(__('Layout & Sidebar Options', kopa_get_domain()), 'kopa-metabox-post-layout-manage', $metaboxes); /** * Add metaboxes "Custom Thumbnails" for POST */ if ('true' == KopaOptions::get_option('is_use_custom_thumbnail', 'false')) { $sizes = KopaInit::get_image_sizes(); if (!empty($sizes)) { $second_metaboxes['fields'] = array(); $second_metaboxes['fields'][] = array('type' => 'checkbox', 'id' => KOPA_OPT_PREFIX . 'is_use_custom_thumbnail', 'name' => KOPA_OPT_PREFIX . 'is_use_custom_thumbnail', 'default' => 'false', 'classes' => array('ckb_is_use_custom_thumbnail_toggle'), 'label' => __('Is use custom thumbnail for this post', kopa_get_domain()), 'is_append_label_before_control' => false, 'help' => NULL, 'attributes' => array('onchange' => 'KopaMetabox.isUseCustomThumbnailToggle(event, jQuery(this));')); foreach ($sizes as $name => $size) { $second_metaboxes['fields'][] = array('type' => 'media', 'id' => KOPA_OPT_PREFIX . "thumbnail_{$name}", 'name' => KOPA_OPT_PREFIX . "thumbnail_{$name}", 'label' => $size['name'], 'help' => $size['desc'], 'default' => ''); } $post->add_meta_box(__('Custom Thumbnails', kopa_get_domain()), 'kopa-metabox-post-custom-thumbnail', $second_metaboxes); } } /** * Add metaboxes "SEO" for Post */ if ('true' == KopaOptions::get_option('seo_status', 'false')) { $metaboxes['fields'] = array(array('type' => 'textarea', 'id' => KOPA_OPT_PREFIX . 'seo_keywords', 'name' => KOPA_OPT_PREFIX . 'seo_keywords', 'label' => __('Keywords', kopa_get_domain()), 'help' => __('Enter keyword(s) of current post, separated by comma.', kopa_get_domain()), 'classes' => array('linedtextarea'), 'attributes' => array('rows' => 4), 'default' => ''), array('type' => 'textarea', 'id' => KOPA_OPT_PREFIX . 'seo_descriptions', 'name' => KOPA_OPT_PREFIX . 'seo_descriptions', 'label' => __('Description', kopa_get_domain()), 'help' => __('Enter description of current post', kopa_get_domain()), 'classes' => array('linedtextarea'), 'attributes' => array('rows' => 4), 'default' => '')); $post->add_meta_box(__('SEO - Search engine optimization', kopa_get_domain()), 'kopa-metabox-post-seo', $metaboxes); } /**
/** * @package Kopa * @subpackage Core * @author thethangtran <*****@*****.**> * @since 1.0.0 */ function kopa_init_database() { $kopa_is_database_setup = get_option(KOPA_OPT_PREFIX . 'database_setup'); if ($kopa_is_database_setup !== KOPA_INIT_VERSION) { $kopa_setting = array('home' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'front-page' => array('layout_slug' => 'front-page-1', 'sidebars' => array('front-page-1' => array('sidebar_1', 'sidebar_3', 'sidebar_4', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-2' => array('sidebar_1', 'sidebar_2', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-3' => array('sidebar_1', 'sidebar_2', 'sidebar_3', 'sidebar_4', 'sidebar_5', 'sidebar_6', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'static-page-1' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'contact-page' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'static-page-timeline' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'post' => array('layout_slug' => 'single-post-1', 'sidebars' => array('single-post-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'page' => array('layout_slug' => 'static-page-1', 'sidebars' => array('static-page-1' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'contact-page' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'static-page-timeline' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-1' => array('sidebar_1', 'sidebar_3', 'sidebar_4', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-2' => array('sidebar_1', 'sidebar_2', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-3' => array('sidebar_1', 'sidebar_2', 'sidebar_3', 'sidebar_4', 'sidebar_5', 'sidebar_6', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'taxonomy' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'author' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'search' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'archive' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), '_404' => array('layout_slug' => 'error-404', 'sidebars' => array('error-404' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12')))); $kopa_sidebar = KopaInit::get_sidebars(); update_option(KOPA_OPT_PREFIX . 'layout_settings', $kopa_setting); update_option(KOPA_OPT_PREFIX . 'database_setup', KOPA_INIT_VERSION); //if (KOPA_DOMAIN . '-layout-setting-v1' == KOPA_INIT_VERSION) { update_option(KOPA_OPT_PREFIX . 'sidebars', $kopa_sidebar); //} $saved_opts = get_option(KOPA_OPT_PREFIX . 'options'); if (!$saved_opts) { $tabs = KopaInit::get_theme_option_fields(); $opts = array(); foreach ($tabs as $tab) { foreach ($tab['groups'] as $groups) { foreach ($groups['fields'] as $field) { kopa_save_theme_options_loop($field, $opts); } } } update_option(KOPA_OPT_PREFIX . 'options', $opts); } } $sidebars = get_option(KOPA_OPT_PREFIX . 'sidebars'); foreach ($sidebars as $key => $value) { if ('sidebar_hide' != $key) { $sidebar_args = KopaInit::get_sidebar_args(); $sidebar_args['name'] = $value; $sidebar_args['id'] = $key; register_sidebar($sidebar_args); } } }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $uri = $instance['uri']; $description = $instance['description']; echo $before_widget; $social_links = KopaInit::get_social_icons(); echo '<div class="like-box clearfix">'; foreach ($social_links as $slug => $info) { $href = KopaOptions::get_option("social_link_{$slug}"); if ('rss' == $slug) { if (empty($href)) { $href = get_bloginfo_rss('rss2_url'); } elseif ('HIDE' == $href) { $href = ''; } } if (!empty($href)) { printf('<a class="kopa-social-link" href="%1$s" target="_blank" title="%2$s" rel="nofollow"><i class="%3$s"></i></a>', $href, $info['title'], $info['icon']); } } echo '</div>'; if ($uri) { ?> <div class="kp-newsletter"> <?php if (!empty($title)) { echo $before_title . $title . $after_title; } echo $description ? "<p>{$description}</p>" : ''; ?> <form class="newsletter-form clearfix" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=<?php echo $uri; ?> ', 'popupwindow', 'scrollbars=yes,width=550,height=520'); return true;"> <p class="input-email clearfix"> <input type="text" name="email" value="" placeholder="<?php _e('Your Email', kopa_get_domain()); ?> " class="form-control email"> <input type="hidden" value="<?php echo $uri; ?> " name="uri"/> <input type="hidden" name="loc" value="en_US"/> <input type="submit" value="<?php _e('Subscribe', kopa_get_domain()); ?> " class="submit"> </p> </form> <div class="newsletter-response"></div> </div> <?php } echo $after_widget; }
* @subpackage Core * @author thethangtran <*****@*****.**> * @since 1.0.0 * */ $theme_options_args = array(); $theme_options_args['wrap_begin'] = '<div class="kopa-opt-fields clearfix"><div class="row clearfix">'; $theme_options_args['wrap_end'] = '</div></div>'; $theme_options_args['label_begin'] = '<div class="col-xs-3 kopa-opt-field-label">'; $theme_options_args['label_end'] = '</div>'; $theme_options_args['control_begin'] = '<div class="col-xs-9">'; $theme_options_args['control_end'] = '</div>'; $theme_options_args['help_classes'] = array(); $theme_options_args['help_begin'] = '<div class="col-xs-9 col-xs-offset-3">'; $theme_options_args['help_end'] = '</div>'; $tabs = KopaInit::get_theme_option_fields(); ?> <img id="kopa-loading-gif" src="<?php echo get_template_directory_uri() . '/library/images/loading.gif'; ?> "> <div id="kopa-cpanel-wrapper" class="clearfix"> <div class="col-left pull-left"> <ul class="kopa-cpanel-nav"> <?php $is_first = true; foreach ($tabs as $slug => $tab) { $icon = isset($tab['icon']) ? sprintf('<i class="%1$s"></i>', $tab['icon']) : ''; if ($is_first) { printf('<li><a class="kopa-tab-link active" href="#tab-%s">%s <span>%s</span></a></li>', $slug, $icon, $tab['title']); $is_first = false;
/** * @package Kopa * @subpackage Core * @author thethangtran <*****@*****.**> * @since 1.0.0 */ function kopa_get_social_links() { $social_links = KopaInit::get_social_icons(); ?> <ul id="header-social-links"> <?php foreach ($social_links as $slug => $info) { $href = KopaOptions::get_option("social_link_{$slug}"); if ('rss' == $slug) { if (empty($href)) { $href = get_bloginfo_rss('rss2_url'); } elseif ('HIDE' == $href) { $href = ''; } } if (!empty($href)) { printf('<li><a class="kopa-social-link" href="%s" target="_blank" title="%s" rel="nofollow"><i class="%s"></i></a></li>', $href, $info['title'], $info['icon']); } } ?> </ul> <?php }