function my_box_post_layout($post) { $layouts = array('right' => get_template_directory_uri() . '/media/admin/images/left.layout.png', 'left' => get_template_directory_uri() . '/media/admin/images/right.layout.png', 'full' => get_template_directory_uri() . '/media/admin/images/full.layout.png'); $sidebars = myThemes::get('sidebars-list'); if (!is_array($sidebars)) { $sidebars = array(); } $values = array('main-sidebar' => __('Main Sidebar', 'myThemes'), 'front-page-sidebar' => __('Front Page Sidebar', 'myThemes'), 'page-sidebar' => __('Page Sidebar', 'myThemes'), 'single-sidebar' => __('Single Sidebar', 'myThemes'), 'additional-sidebar' => __('Additional Sidebar', 'myThemes')); /* LAYOUT */ echo ahtml::template(array('type' => array('template' => 'inline', 'input' => 'logic'), 'label' => __('Use custom layout', 'myThemes'), 'fieldName' => 'use-post-layout', 'action' => "{'t' : '.mythemes-post-layout' , 'f' : '-' }", 'value' => meta::get($post->ID, 'use-post-layout'))); $use_post_layout = meta::get($post->ID, 'use-post-layout'); if (strlen($use_post_layout) == 0 || $use_post_layout === "0") { $classes = 'mythemes-post-layout hidden'; } else { $classes = 'mythemes-post-layout'; } if ($post->post_type == 'post') { $type = 'single'; } else { $type = $post->post_type; } $rett = ahtml::template(array('type' => array('template' => 'inline', 'input' => 'imageSelect'), 'values' => $layouts, 'coll' => 2, 'label' => __('Select Layout', 'myThemes'), 'fieldName' => 'post-layout', 'value' => meta::dget($post->ID, 'post-layout', myThemes::get($type . '-layout')), 'action' => "[ 'hs' , { 'full' : '.mythemes-layout-sidebar' } ]")); if (meta::get($post->ID, 'post-layout') == 'full') { $sidebarClass = 'mythemes-layout-sidebar hidden'; } else { $sidebarClass = 'mythemes-layout-sidebar'; } $rett .= ahtml::template(array('type' => array('template' => 'inline', 'input' => 'select'), 'values' => $values, 'label' => __('Select sidebar', 'myThemes'), 'fieldName' => 'post-sidebar', 'templateClass' => $sidebarClass, 'value' => meta::dget($post->ID, 'post-sidebar', myThemes::get($type . '-sidebar')))); echo ahtml::template(array('type' => array('template' => 'code'), 'content' => $rett, 'templateClass' => $classes)); }
static function toggleSave() { $key = isset($_POST['option']) && $_POST['option'] ? $_POST['option'] : exit; if (get_theme_mod($key)) { remove_theme_mod($key); $value = 0; $message = __('Successful disabled option!', 'myThemes'); } else { set_theme_mod($key, 1); $value = 1; $message = __('Successful enabled option!', 'myThemes'); } echo str_replace('"', "'", json_encode(array('message' => $message, 'label' => ahtml::getLogicButtonValue(array('value' => $value)), 'value' => $value, 'nofade' => 0))); exit; }
static function boxMultipleForm($box, $pageSlug, $sett) { $result = '<div>'; foreach ($sett as $fieldName => &$d) { if (isset($d['type']['box']) && isset($d['skip']) && $d['type']['box'] == $box) { $d['fieldName'] = $fieldName; $d['pageSlug'] = $pageSlug; $d['value'] = sett::get($pageSlug . '-' . $fieldName); $result .= '<form method="post">'; $result .= ahtml::template($d); $result .= '</form>'; } } $result .= '</div>'; return $result; }
static function pageContent( $pageSlug ) { $st = & acfg::$pages[ $pageSlug ][ 'content' ]; if( !empty( $_POST ) ){ foreach( $_POST as $key => & $d ){ if( substr( $key , 0 , 8 ) == 'mytheme-' ){ $fName = str_replace( $pageSlug . '-' , '' , $key ); /* VALIDATE INFO BEFORE SAVE */ $validator = ''; if( isset( $_POST[ $key ] ) && isset( $st[ $fName ] ) ) $validator = ahtml::validator( $_POST[ $key ] , ahtml::getValidator( $st[ $fName ] ) ); set_theme_mod( $key , $validator ); } } } $cfgs = & acfg::$pages[ $pageSlug ]; echo '<div class="admin-content">'; /* PAGE TITLE */ echo '<div class="title">'; if( isset( $cfgs[ 'title' ] ) ) echo '<h2>' . $cfgs[ 'title' ] . '</h2>'; if( isset( $cfgs[ 'description' ] ) ) echo '<p>' . $cfgs[ 'description' ] . '</p>'; echo '</div>'; /* SUBMIT FORM */ if( !isset( $cfgs[ 'update' ] ) || ( isset( $cfgs[ 'update' ] ) && $cfgs['update'] ) ){ echo '<form method="post">'; } settings_fields( $pageSlug ); if( isset( $cfgs[ 'content' ] ) && !empty( $cfgs[ 'content' ] ) ) { foreach( $cfgs[ 'content' ] as $fieldName => $sett ) { $sett[ 'pageSlug' ] = $pageSlug; $sett[ 'fieldName' ] = $fieldName; $sett[ 'value' ] = sett::get( $pageSlug . '-' . $fieldName ); echo ahtml::template( $sett ); } } /* SUBMIT BUTTON */ if( !isset( $cfgs[ 'update' ] ) || ( isset( $cfgs[ 'update' ] ) && $cfgs['update'] ) ){ echo '<div class="standart-generic-field submit">'; echo '<div class="field">'; echo '<input type="submit" class="button-primary my-submit" value="' . __( 'Update Settings' , "mythemes" ) . '"/>'; echo '</div>'; echo '</div>'; echo '</form>'; } echo '</div>'; }
static function pageContent($pageSlug) { $cfgs =& myThemes_acfg::$pages[$pageSlug]; $file = str_replace('mythemes-', '', $pageSlug); $sett_ = get_template_directory() . '/cfg/admin/settings'; $sett_dir = $sett_ . '/' . $file; if (file_exists($sett_dir . '.php')) { include $sett_dir . '.php'; } $st = $cfgs['content']; if (!empty($_POST)) { foreach ($_POST as $key => &$d) { if (substr($key, 0, 9) == 'mythemes-') { $fName = str_replace('mythemes-', '', $key); /* VALIDATE INFO BEFORE SAVE */ $validator = ''; if (isset($_POST[$key]) && isset($st[$fName])) { $validator = ahtml::validator($_POST[$key], ahtml::getValidator($st[$fName])); } set_theme_mod($key, $validator); } } } $rett = '<td class="admin-content">'; /* PAGE TITLE */ $rett .= '<div class="title">'; if (isset($cfgs['title'])) { $rett .= '<h2>' . $cfgs['title'] . '</h2>'; } if (isset($cfgs['description'])) { $rett .= '<p>' . $cfgs['description'] . '</p>'; } $rett .= '</div>'; /* SUBMIT FORM */ if (!isset($cfgs['update']) || isset($cfgs['update']) && $cfgs['update']) { $rett .= '<form method="post">'; } settings_fields('mythemes'); $content = $cfgs['content']; if (isset($content) && !empty($content)) { foreach ($content as $fieldName => $sett) { $sett['pageSlug'] = $pageSlug; $sett['fieldName'] = $fieldName; $sett['value'] = sett::get('mythemes-' . $fieldName); $rett .= ahtml::template($sett); } } /* SUBMIT BUTTON */ if (!isset($cfgs['update']) || isset($cfgs['update']) && $cfgs['update']) { $rett .= '<div class="standart-generic-field submit top_delimiter">'; $rett .= '<div class="field">'; $rett .= '<input type="submit" class="button button-primary my-submit button-hero" value="' . __('Update Settings', "myThemes") . '"/>'; $rett .= '</div>'; $rett .= '</div>'; $rett .= '</form>'; } $rett .= '</td>'; $rett .= '<td class="mythemes-credits">'; $rett .= '<div class="title">'; $rett .= '<h3>myThem.es Links</h3>'; $rett .= '</div>'; $rett .= (include get_template_directory() . '/fw/admin/widget.php'); $rett .= '</td>'; $rett .= '</tr>'; $rett .= '</table>'; return $rett; }