function field_template_path($field) { $theme_data = rw_get_theme_data(); $template_path = null; if (file_exists(THEME_DIR . 'data-types/' . $field->type . '.php')) { $template_path = THEME_DIR . 'data-types/' . $field->type . '.php'; } else { $found_in_theme_dirs = false; if (is_dir(THEME_DIR . 'data-types')) { foreach (array_diff(scandir(THEME_DIR . 'data-types'), array('..', '.', 'data-type.php')) as $name) { if (is_dir(THEME_DIR . 'data-types/' . $name) && file_exists(THEME_DIR . 'data-types/' . $name . "/" . $field->type . '.php')) { $template_path = THEME_DIR . 'data-types/' . $name . "/" . $field->type . '.php'; $found_in_theme_dirs = true; break; } } } $found_in_framework_dirs = false; if (!$found_in_theme_dirs) { foreach (array_diff(scandir(get_theme_root() . '/' . $theme_data['Template'] . '/data-types'), array('..', '.', 'data-type.php')) as $name) { if (is_dir(get_theme_root() . '/' . $theme_data['Template'] . '/data-types/' . $name) && file_exists(get_theme_root() . '/' . $theme_data['Template'] . '/data-types/' . $name . "/" . $field->type . '.php')) { $template_path = get_theme_root() . '/' . $theme_data['Template'] . '/data-types/' . $name . "/" . $field->type . '.php'; $found_in_framework_dirs = true; break; } } } if (!$found_in_framework_dirs) { $template_path = get_theme_root() . '/' . $theme_data['Template'] . '/data-types/' . $field->type . '.php'; } } if (file_exists($template_path)) { return $template_path; } else { return false; } }
echo $redirect; // escaped above } } else { $this->view('theme-conf'); } break; case 'delete-theme': if (isset($_REQUEST['confirm'])) { if (isset($_REQUEST['name']) && $_REQUEST['name'] != 'runway') { $developer_tools->delete_child_theme($_REQUEST['name']); } require_once 'views/themes-list.php'; } else { if (isset($_REQUEST['name'])) { $del_theme_info = rw_get_theme_data($themes_path . '/' . $_REQUEST['name']); include_once 'views/del-theme-confirmation.php'; } } break; case 'new-theme': $developer_tools->mode = 'new'; if (isset($_POST['theme_options'])) { $post = stripslashes_deep($_POST['theme_options']); $errors = $developer_tools->validate_theme_settings($post); if (count($errors)) { $options = $post; $this->view('theme-conf'); } else { $options = $developer_tools->build_and_save_theme($post); require_once 'views/themes-list.php';
function check_theme_ID($folder = false) { global $shortname; if (!function_exists('WP_Filesystem')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); global $wp_filesystem; $settings = get_settings_json($folder); if (isset($settings['Name'])) { $themeInfo = rw_get_theme_data(); $theme_name_stylecss = $themeInfo['Name']; if (isset($settings['ThemeID'])) { $theme_prefix_old = isset($settings['ThemeID']) ? $settings['ThemeID'] : $shortname; if (change_theme_prefix($theme_prefix_old, $settings['ThemeID'])) { $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE); } } if (empty($theme_name_stylecss)) { $theme_name_stylecss = __('Unknown Theme (Theme Name in style.css is empty)', 'framework'); } if (isset($settings['Name']) && $theme_name_stylecss != $settings['Name']) { $link = IS_CHILD ? admin_url('admin.php?page=themes') : admin_url('themes.php'); if (isset($_GET['create-theme-id'])) { if ($_GET['create-theme-id']) { $theme_prefix_old = isset($settings['ThemeID']) ? $settings['ThemeID'] : $shortname; $theme_id = create_theme_ID(); $settings['ThemeID'] = $theme_id; if (change_theme_prefix($theme_prefix_old, $settings['ThemeID'])) { $settings['Name'] = $theme_name_stylecss; $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE); } } else { $settings['Name'] = $theme_name_stylecss; $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE); } $redirect = '<script type="text/javascript">window.location = "' . esc_url($link) . '";</script>'; echo $redirect; // escaped above } add_action('admin_notices', 'ask_new_theme', 10, 3); do_action('admin_notices', $settings['Name'], $theme_name_stylecss, $link); remove_action('admin_notices', 'ask_new_theme'); } else { return true; } } }
public function render_content($vals = null) { $input_value = $vals != null ? $this->field->saved : $this->get_value(); $font_family = isset($this->field->family) ? $this->field->family : 'Open Sans'; $font_weight = $this->field->weight != '' ? $this->field->weight : 'normal'; $font_size = $this->field->size != '' ? $this->field->size : '20px'; $font_style = isset($this->field->style) && $this->field->style != '' ? $this->field->style : 'normal'; $font_color = isset($this->field->color) && $this->field->color != '' ? $this->field->color : '#000000'; $previewText = isset($this->field->previewText) ? $this->field->previewText : ''; global $developer_tools; $current_theme = rw_get_theme_data(); $t = runway_admin_themes_list_prepare($current_theme); $options = $developer_tools->load_settings($t['folder']); $google_fonts = $this->wp_get_google_webfonts_list(isset($options['WebFontAPIKey']) ? $options['WebFontAPIKey'] : ''); if (is_array($input_value)) { if (isset($input_value['family'])) { $font_family = $input_value['family']; } if (isset($input_value['style'])) { $font_style = $input_value['style']; } if (isset($input_value['weight'])) { $font_weight = $input_value['weight']; } if (isset($input_value['size'])) { $font_size = $input_value['size']; } if (isset($input_value['color'])) { $font_color = $input_value['color']; } if (isset($input_value['previewText'])) { $previewText = $input_value['previewText']; } } ?> <div class="<?php echo esc_attr($this->field->alias); ?> custom-data-type"> <div style="font-family: <?php echo esc_attr($font_family); ?> ; <?php if (isset($font_style) && !empty($font_style)) { ?> font-style: <?php echo esc_attr($font_style); ?> ; <?php } ?> font-weight: <?php echo esc_attr($font_weight); ?> ; font-size: <?php echo esc_attr($font_size); ?> ; <?php if (isset($font_color) && !empty($font_color)) { ?> color: <?php echo esc_attr($font_color); ?> <?php } ?> "> <?php echo $previewText != '' ? $previewText : ucwords(str_replace('-', ' ', $font_family)); ?> </div> <input class="custom-data-type" <?php echo parent::add_data_conditional_display($this->field); ?> data-set="<?php echo esc_attr($this->field->alias); ?> [previewText]" name="<?php echo esc_attr($this->field->alias); ?> [previewText]" value="<?php echo esc_attr($previewText); ?> " type="hidden"/> <input class="custom-data-type" <?php echo parent::add_data_conditional_display($this->field); ?> data-set="<?php echo esc_attr($this->field->alias); ?> [family]" name="<?php echo esc_attr($this->field->alias); ?> [family]" value="<?php echo esc_attr($font_family); ?> " type="hidden"/> <input class="custom-data-type" <?php echo parent::add_data_conditional_display($this->field); ?> data-set="<?php echo esc_attr($this->field->alias); ?> [style]" name="<?php echo esc_attr($this->field->alias); ?> [style]" value="<?php echo esc_attr($font_style); ?> " type="hidden"/> <input class="custom-data-type" <?php echo parent::add_data_conditional_display($this->field); ?> data-set="<?php echo esc_attr($this->field->alias); ?> [weight]" name="<?php echo esc_attr($this->field->alias); ?> [weight]" value="<?php echo esc_attr($font_weight); ?> " type="hidden"/> <input class="custom-data-type" <?php echo parent::add_data_conditional_display($this->field); ?> data-set="<?php echo esc_attr($this->field->alias); ?> [size]" name="<?php echo esc_attr($this->field->alias); ?> [size]" value="<?php echo esc_attr($font_size); ?> " type="hidden"/> <input class="custom-data-type" <?php echo parent::add_data_conditional_display($this->field); ?> data-set="<?php echo esc_attr($this->field->alias); ?> [color]" name="<?php echo esc_attr($this->field->alias); ?> [color]" value="<?php echo esc_attr($font_color); ?> " type="hidden"/> <div class="<?php echo esc_attr($this->field->alias); ?> "> <a href="#" onclick="return false" class="edit-font-options-a button"><?php echo __('Edit Font Options', 'framework'); ?> </a> <div class="font-options-container pop" style="display:none"> <div class="settings-font-options-dialog"> <div class="toogle-font-select-container"> <div class="settings-container preview-text-input"> <label class="settings-title"> <?php echo __('Preview text', 'framework'); ?> : </label> <div class="settings-in"> <input data-set="<?php echo esc_attr($this->field->alias); ?> [_previewText]" name="<?php echo esc_attr($this->field->alias); ?> [_previewText]" value="<?php echo esc_attr($previewText); ?> " type="text" placeholder="<?php echo __('Preview Test', 'framework'); ?> "/> <p class="settings-field-caption description"><?php echo __('Preview text.', 'framework'); ?> </p> </div> <div class="clear"></div> </div> <div class="ui-dialog-content"> <div class="settings-container"> <label class="settings-title"> <?php echo __('Family', 'framework'); ?> : </label> <div class="settings-in"> <select data-set="<?php echo esc_attr($this->field->alias); ?> [_family]" name="<?php echo esc_attr($this->field->alias); ?> [_family]" data-type="font-select" class="settings-select"> <?php if (is_array($google_fonts) && !empty($google_fonts)) { ?> <?php foreach ($google_fonts as $font) { ?> <option <?php if ($font_family == $font) { echo "selected='true'"; } ?> value="<?php echo esc_attr($font); ?> "><?php echo esc_attr($font); ?> </option> <?php } ?> <?php } else { ?> <option selected="true" value="open sans"><?php echo __('Open Sans', 'framework'); ?> </option> <?php } ?> </select> </div> <div class="clear"></div> </div> <div class="settings-container"> <label class="settings-title"> <?php echo __('Style', 'framework'); ?> : </label> <div class="settings-in"> <select data-set="<?php echo esc_attr($this->field->alias); ?> [_style]" name="<?php echo esc_attr($this->field->alias); ?> [_style]" data-type="font-select" class="settings-select"> <option <?php if ($font_style == '' || $font_style == 'normal') { ?> selected="true" <?php } ?> value="normal"><?php echo __('Normal', 'framework'); ?> </option> <option <?php if ($font_style == 'italic') { ?> selected="true" <?php } ?> value="italic"><?php echo __('Italic', 'framework'); ?> </option> </select> </div> <div class="clear"></div> </div> <div class="settings-container"> <label class="settings-title"> <?php echo __('Weight', 'framework'); ?> : </label> <div class="settings-in"> <input data-set="<?php echo esc_attr($this->field->alias); ?> [_weight]" name="<?php echo esc_attr($this->field->alias); ?> [_weight]" value="<?php if ($this->field->weight == '') { ?> bold<?php } else { echo esc_attr($font_weight); } ?> " type="text" data-type="font-select" /> <p class="settings-field-caption description"><?php echo __('normal, bold, 300, 600, 800', 'framework'); ?> </p> </div> <div class="clear"></div> </div> <div class="settings-container"> <label class="settings-title"> <?php echo __('Size', 'framework'); ?> : </label> <div class="settings-in"> <input data-set="<?php echo esc_attr($this->field->alias); ?> [_size]" name="<?php echo esc_attr($this->field->alias); ?> [_size]" value="<?php if ($this->field->size == '') { ?> 32px<?php } else { echo esc_attr($font_size); } ?> " type="text" data-type="font-select" /> <p class="settings-field-caption description"><?php echo __('12, 24px, 1em, 1.75', 'framework'); ?> </p> </div> <div class="clear"></div> </div> <div class="settings-container"> <label class="settings-title"> <?php echo __('Color', 'framework'); ?> : </label> <div class="settings-in"> <input data-set="<?php echo esc_attr($this->field->alias); ?> [_color]" name="<?php echo esc_attr($this->field->alias); ?> [_color]" value="<?php echo $font_color != '' ? $font_color : '#000000'; ?> " type="text" class="color-picker-hex" data-type="font-select" /> </div> <div class="clear"></div> </div> </div> <input class="button" type="button" value="<?php _e('Close', 'framework'); ?> " name="<?php echo esc_attr($this->field->alias); ?> _save"/> <!-- <a href="#" class="<?php echo esc_attr($this->field->alias); ?> _cancel"><?php _e('Cancel', 'framework'); ?> </a> --> </div> <script type="text/javascript"> var alias = '<?php echo esc_js($this->field->alias); ?> '; jQuery(document).ready(function($){ function deselect(e) { $('.<?php echo esc_js($this->field->alias); ?> .pop').slideFadeToggle(function() { e.removeClass('font-edit'); }); } $.fn.slideFadeToggle = function(easing, callback) { return this.animate({ opacity: 'toggle', height: 'toggle' }, 'fast', easing, callback); }; jQuery('.<?php echo esc_js($this->field->alias); ?> .toogle-font-select-container .color-picker-hex').wpColorPicker({ change: function () { var hexcolor = jQuery( this ).wpColorPicker( 'color' ); //setTimeout(function () { $('.<?php echo esc_js($this->field->alias); ?> .toogle-font-select-container .color-picker-hex').attr('value', hexcolor).val(hexcolor).trigger('change'); //}, 50); }}); //); $('input[name=<?php echo esc_js($this->field->alias); ?> _save]').on('click', function(e){ e.preventDefault(); e.stopPropagation(); var alias = "<?php echo esc_js($this->field->alias); ?> "; $('input[name="'+alias+'[previewText]"]').val($('input[name="'+alias+'[_previewText]"]').val()); $('input[name="'+alias+'[family]"]').val($('select[name="'+alias+'[_family]"]').val()); $('input[name="'+alias+'[style]"]').val($('select[name="'+alias+'[_style]"]').val()); $('input[name="'+alias+'[weight]"]').val($('input[name="'+alias+'[_weight]"]').val()); $('input[name="'+alias+'[size]"]').val($('input[name="'+alias+'[_size]"]').val()); $('input[name="'+alias+'[color]"]').val($('input[name="'+alias+'[_color]"]').val()); if ( wp.customize ) { var api = wp.customize; var values_array = {}; $('.<?php echo esc_js($this->field->alias); ?> .settings-font-options-dialog .toogle-font-select-container input[type=text]').each(function(){ var name = $(this).attr('name').replace(alias, '').replace("[", "").replace("]", ""); values_array[name] = $(this).val(); //api.instance($(this).attr('name')).set($(this).val()); }); $('.<?php echo esc_js($this->field->alias); ?> .toogle-font-select-container select option:selected').each(function(){ var name = $(this).parent('select').attr('name').replace(alias, '').replace("[", "").replace("]", ""); values_array[name] = $(this).attr('value'); //api.instance($(this).parent('select').attr('name')).set($(this).attr('value')); }); var name = $('.<?php echo esc_js($this->field->alias); ?> .toogle-font-select-container .color-picker-hex').attr('name').replace(alias, '').replace("[", "").replace("]", ""); values_array[name] = $('.<?php echo esc_js($this->field->alias); ?> .toogle-font-select-container .color-picker-hex').val(); api.instance(alias).set(values_array); //api.instance($('.<?php echo esc_js($this->field->alias); ?> .edit-font-options-inner .color-picker-hex').attr('name')).set($('.<?php echo esc_js($this->field->alias); ?> .edit-font-options-inner .color-picker-hex').val()); } deselect($(this)); }); $('.<?php echo esc_js($this->field->alias); ?> .toogle-font-select-container .color-picker-hex').wpColorPicker({ change: function () { var hexcolor = jQuery( this ).wpColorPicker( 'color' ); //setTimeout(function () { $('.<?php echo esc_js($this->field->alias); ?> .toogle-font-select-container .color-picker-hex').attr('value', hexcolor).val(hexcolor).trigger('change'); //}, 50); }}); $('.<?php echo esc_js($this->field->alias); ?> a.edit-font-options-a').on('click', function(e){console.log('11111'); e.preventDefault(); e.stopPropagation(); if($(this).hasClass('font-edit')) { deselect($(this)); } else { $(this).addClass('font-edit'); $('.<?php echo esc_js($this->field->alias); ?> .pop').slideFadeToggle(); } }); /*$('.<?php echo esc_js($this->field->alias); ?> _cancel').on('click', function(e) { e.preventDefault(); e.stopPropagation(); deselect($(this)); //return false; });*/ }); </script> </div> </div> </div> </div> <?php }
<?php echo __('A child theme can be run on any WordPress install with the Runway framework active. You can use Runway to setup custom theme options, menus and many other features of a child theme. Completed themes can be downloaded as a child or standalone version. A standalone theme may be installed on any WordPress install regardless of having Runway active', 'framework'); ?> . </p> <br> <?php $themes_list = $developer_tools->search_themes(); $tmp_themes = array(); foreach ($themes_list as $key => $theme) { $tmp_themes[] = wp_get_theme($theme['Folder']); } $js_themes = wp_prepare_themes_for_js($tmp_themes); wp_localize_script('themes-manager-themes', '_wpThemeSettings', array('themes' => $js_themes, 'settings' => array('canInstall' => !is_multisite() && current_user_can('install_themes'), 'installURI' => !is_multisite() && current_user_can('install_themes') ? admin_url('theme-install.php') : null, 'confirmDelete' => __("Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete."), 'adminUrl' => parse_url(admin_url(), PHP_URL_PATH)), 'l10n' => array('addNew' => __('Add New Theme', 'framework'), 'search' => __('Search Installed Themes', 'framework'), 'searchPlaceholder' => __('Search installed themes...', 'framework')))); $current_theme = rw_get_theme_data(); // Set the variables $t = runway_admin_themes_list_prepare($current_theme); unset($themes_list[$current_theme['Folder']]); ?> <div class="theme-browser rendered"> <div class="themes"> <div class="theme active" tabindex="0" data-themeid="<?php echo esc_attr($current_theme['Folder']); ?> "> <div class="theme-screenshot"> <img alt="" src="<?php echo esc_url(isset($t['image']) && $t['image'] != "" ? $t['image'] : FRAMEWORK_URL . 'framework/images/runway-child-theme-default-background.png'); ?>
/** * build_alone_theme - make alone theme package * * @param mixed $theme_name Theme name. * @param mixed $ts Time stamp to make unique download archive name. * * @access public * * @return mixed Value. */ function build_alone_theme($theme_name = null, $ts = null) { if (!function_exists('WP_Filesystem')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); global $wp_filesystem; if (class_exists('ZipArchive')) { do_action('before_build_alone_theme', $theme_name); global $extm; if (!$theme_name || !$ts) { return false; } if (!is_writable($this->themes_path . '/' . $theme_name)) { wp_die(__('Please set write permissions for', 'framework') . ' ' . $this->themes_path . '/' . $theme_name . ' ' . __('and then refresh page', 'framework')); } $zip = new ZipArchive(); $packages_storage_path = "{$this->themes_path}/{$theme_name}/download"; if (!file_exists($packages_storage_path)) { mkdir($packages_storage_path); } $zip_file_name = "{$theme_name}-({$ts}).a.zip"; $zip->open($packages_storage_path . '/' . $zip_file_name, ZIPARCHIVE::CREATE); $source = "{$this->themes_path}/runway-framework"; $source = str_replace('\\', '/', realpath($source)); // Copy framework and data types folder $zip->addEmptyDir($theme_name . '/framework/'); $framework_dir = FRAMEWORK_DIR . 'framework/'; $exclude = array('themes', 'includes'); $this->add_to_zip_r($framework_dir, $theme_name . '/framework/', $zip, $exclude); $zip->addEmptyDir($theme_name . '/framework/includes/'); $framework_dir = FRAMEWORK_DIR . 'framework/includes/'; $exclude = array('report-manager', 'download-directory', 'dashboard', 'pointers', 'auth-manager', 'options-builder', 'theme-updater'); $this->add_to_zip_r($framework_dir, $theme_name . '/framework/includes/', $zip, $exclude); $zip->addEmptyDir($theme_name . '/data-types/'); $framework_dir = FRAMEWORK_DIR . 'data-types/'; $this->add_to_zip_r($framework_dir, $theme_name . '/data-types/', $zip); // Add active extensions in package $zip->addEmptyDir($theme_name . '/extensions/'); foreach ($extm->get_active_extensions_list($theme_name) as $ext) { if (is_string($ext)) { $ext_dir = explode('/', $ext); $file = $source . '/extensions/' . $ext_dir[0] . '/'; $this->add_to_zip_r($file, $theme_name . '/extensions/' . $ext_dir[0] . '/', $zip); } } // merge functions.php $functions = file_exists($source . '/functions.php') ? $wp_filesystem->get_contents($source . '/functions.php') : ''; if (file_exists("{$this->themes_path}/{$theme_name}/functions.php")) { $functions .= $wp_filesystem->get_contents("{$this->themes_path}/{$theme_name}/functions.php"); } $zip->addFromString($theme_name . '/functions.php', $functions); // build plugin header $theme_data = rw_get_theme_data(get_theme_root() . '/' . $theme_name); $theme_data['Tags'] = implode(' ', $theme_data['Tags']); // $theme_data['Icon'] = rw_get_custom_theme_data('Icon', get_theme_root().'/'.$theme_name); $theme_data['License'] = rw_get_custom_theme_data('License', get_theme_root() . '/' . $theme_name); $theme_data['LicenseURI'] = rw_get_custom_theme_data('License URI', get_theme_root() . '/' . $theme_name); $css = $this->build_theme_css($theme_data, true); // merge style.css $css_ext = file_exists("{$this->themes_path}/{$theme_name}/style.css") ? $wp_filesystem->get_contents("{$this->themes_path}/{$theme_name}/style.css") : ''; $css_ext = $this->remove_plugin_header($css_ext, $theme_data['Name']); $css_ext = $css . $css_ext; $zip->addFromString($theme_name . '/style.css', $css_ext); // copy child theme files $this->add_to_zip_r(get_theme_root() . '/' . $theme_name, $theme_name . '/', $zip, array('download', 'functions.php', 'style.css')); $zip->close(); do_action('after_build_alone_theme', $theme_name, home_url() . "/wp-content/themes/{$theme_name}/download/child/{$zip_file_name}"); return home_url() . "/wp-content/themes/{$theme_name}/download/child/{$zip_file_name}"; } else { wp_die(__('You must have ZipArchive class', 'framework')); } }
<?php /** * Base Runway Configurations * ============================================================================= * * Sets the default framework configurations such as folder locations, variables * and other configurations used by Runway. * */ //----------------------------------------------------------------- // Default variables and information //----------------------------------------------------------------- $themeInfo = rw_get_theme_data(); $themeVersion = trim($themeInfo['Version']); $themeTitle = trim($themeInfo['Title']); $shortname = apply_filters('shortname', sanitize_title($themeTitle . '_')); //................................................................ // shortcuts variables //................................................................ $themeUrl = apply_filters('themeUrl', trailingslashit(get_stylesheet_directory_uri())); $themeDir = apply_filters('themeDir', trailingslashit(get_stylesheet_directory())); $frameworkUrl = apply_filters('frameworkUrl', trailingslashit(get_template_directory_uri())); $frameworkDir = apply_filters('frameworkDir', trailingslashit(get_template_directory())); $frameworkText = apply_filters('frameworkText', 'runway'); $developerMode = apply_filters('developerMode', get_template() == 'runway-framework'); // enables developer mode options $developerTools = apply_filters('developerTools', $developerMode); // makes extra developer tools visible $libsDir = apply_filters('frameworkDir', trailingslashit(get_template_directory() . '/framework/libs/')); //................................................................
function check_theme_ID($folder = false) { global $shortname; if (!function_exists('WP_Filesystem')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); global $wp_filesystem; $settings = get_settings_json($folder); if (isset($settings['Name'])) { $themeInfo = rw_get_theme_data(); $theme_name_stylecss = $themeInfo['Name']; // $is_prefix_ID = ( isset($settings['ThemeID']) && isset($settings['isPrefixID']) )? $settings['isPrefixID'] : false; if (isset($settings['ThemeID'])) { //if( !isset($settings['isPrefixID']) || (isset($settings['isPrefixID']) && !$settings['isPrefixID']) ) { $theme_prefix_old = isset($settings['ThemeID']) ? $settings['ThemeID'] : $shortname; if (change_theme_prefix($theme_prefix_old, $settings['ThemeID'])) { //$settings['isPrefixID'] = true; $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE); //file_put_contents( get_stylesheet_directory() . '/data/settings.json', json_encode($settings) ); } //} } if (isset($settings['Name']) && $theme_name_stylecss != $settings['Name']) { $link = admin_url('admin.php?page=themes'); //$link = home_url().$_SERVER['REQUEST_URI']; if (isset($_GET['create-theme-id'])) { if ($_GET['create-theme-id']) { //$theme_prefix_old = $settings['ThemeID']; $theme_prefix_old = isset($settings['ThemeID']) ? $settings['ThemeID'] : $shortname; $theme_id = create_theme_ID(); $settings['ThemeID'] = $theme_id; if (change_theme_prefix($theme_prefix_old, $settings['ThemeID'])) { $settings['Name'] = $theme_name_stylecss; $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE); //file_put_contents( get_stylesheet_directory() . '/data/settings.json', json_encode($settings) ); } } else { $settings['Name'] = $theme_name_stylecss; $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE); //file_put_contents( get_stylesheet_directory() . '/data/settings.json', json_encode($settings) ); } $redirect = '<script type="text/javascript">window.location = "' . $link . '";</script>'; echo $redirect; } add_action('admin_notices', 'ask_new_theme', 10, 3); do_action('admin_notices', $settings['Name'], $theme_name_stylecss, $link); remove_action('admin_notices', 'ask_new_theme'); } else { return true; } } }
$wp_filesystem->put_contents($pages_dir . $page->settings->page_id . '.json', $page_json, FS_CHMOD_FILE); $pages = $apm->get_pages_list(); include_once 'views/list-pages.php'; } else { wp_die(__('Page not found', 'framework')); } include_once 'views/list-pages.php'; break; case 'reset-fields-page': if (!function_exists('WP_Filesystem')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); global $wp_filesystem; $page = json_decode($wp_filesystem->get_contents($pages_dir . $_GET['page_id'] . '.json')); $theme = rw_get_theme_data(); delete_option($theme['Folder'] . '_' . $page->settings->alias); $pages = $apm->get_pages_list(); include_once 'views/list-pages.php'; break; default: include_once 'views/list-pages.php'; break; } } function get_copy_alias($alias) { global $apm, $alias_; $pages = $apm->get_pages_list(); $check_sum = 0; foreach ($pages as $page) {