mirror of
https://github.com/KevinMidboe/rohnenedre.git
synced 2025-10-29 17:50:37 +00:00
Initial commit. State 04.2021.
This commit is contained in:
11
wp-content/plugins/one-click-child-theme/.gitignore
vendored
Normal file
11
wp-content/plugins/one-click-child-theme/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# OS generated files #
|
||||
######################
|
||||
*/.DS_Store
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
Icon?
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
Binary file not shown.
@@ -0,0 +1,238 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: One-Click Child Theme\n"
|
||||
"POT-Creation-Date: 2015-04-15 14:53-0000\n"
|
||||
"PO-Revision-Date: 2015-04-15 14:54-0000\n"
|
||||
"Last-Translator: Pedro Mendonça <ped.gaspar@gmail.com>\n"
|
||||
"Language-Team: Pedro Mendonça <ped.gaspar@gmail.com>\n"
|
||||
"Language: pt_PT\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.7.5\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
||||
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
||||
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: one-click-child-theme.php:120
|
||||
#, php-format
|
||||
msgid ""
|
||||
"Theme switched! <a href=\"%s\">Click here to edit the child stylesheet</a>."
|
||||
msgstr ""
|
||||
"Tema alterado! <a href=\"%s\">Clique aqui para editar a folha de estilos "
|
||||
"dependente</a>."
|
||||
|
||||
#: one-click-child-theme.php:133
|
||||
#, php-format
|
||||
msgid "Failed to create file: %s"
|
||||
msgstr "Falhou ao criar o ficheiro: %s"
|
||||
|
||||
#: one-click-child-theme.php:140
|
||||
#, php-format
|
||||
msgid "Failed to edit file: %s"
|
||||
msgstr "Falhou ao editar o ficheiro: %s"
|
||||
|
||||
#: one-click-child-theme.php:146
|
||||
msgid "Repaired child theme."
|
||||
msgstr "O tema dependente foi reparado."
|
||||
|
||||
#: one-click-child-theme.php:150
|
||||
msgid "No template file specified."
|
||||
msgstr "Nenhum ficheiro modelo especificado."
|
||||
|
||||
#: one-click-child-theme.php:154
|
||||
#, php-format
|
||||
msgid "Template file %s does not exist in parent theme!"
|
||||
msgstr "Ficheiro modelo %s não existe no tema superior!"
|
||||
|
||||
#: one-click-child-theme.php:161
|
||||
#, php-format
|
||||
msgid "Template file %s already exists in child theme!"
|
||||
msgstr "Ficheiro modelo %s já existe no tema dependente!"
|
||||
|
||||
#: one-click-child-theme.php:168
|
||||
#, php-format
|
||||
msgid "Failed to duplicate file %s!"
|
||||
msgstr "Falhou ao duplicar o ficheiro %s!"
|
||||
|
||||
#: one-click-child-theme.php:175
|
||||
#, php-format
|
||||
msgid "<a href=\"%s\">File %s created!</a>"
|
||||
msgstr "<a href=\"%s\">Ficheiro %s criado!</a>"
|
||||
|
||||
#: one-click-child-theme.php:189
|
||||
#, php-format
|
||||
msgid "Failed to delete file %s!"
|
||||
msgstr "Falhou ao apagar o ficheiro %s!"
|
||||
|
||||
#: one-click-child-theme.php:196
|
||||
#, php-format
|
||||
msgid "404 File not found at %s!"
|
||||
msgstr "Ficheiro 404 não encontrado em %s!"
|
||||
|
||||
#: one-click-child-theme.php:203
|
||||
#, php-format
|
||||
msgid "Unrecognized mimetype at %s!"
|
||||
msgstr "Tipo de media desconhecido em %s!"
|
||||
|
||||
#: one-click-child-theme.php:210
|
||||
#, php-format
|
||||
msgid "Failed to create file %s!"
|
||||
msgstr "Falhou ao criar o ficheiro %s!"
|
||||
|
||||
#: one-click-child-theme.php:216
|
||||
msgid "Successfully changed screenshot."
|
||||
msgstr "Captura de ecrã modificada com sucesso"
|
||||
|
||||
#: one-click-child-theme.php:233
|
||||
msgid "Make a Child Theme"
|
||||
msgstr "Criar um tema dependente"
|
||||
|
||||
#: one-click-child-theme.php:234
|
||||
msgid "Child Theme"
|
||||
msgstr "Tema dependente"
|
||||
|
||||
#: one-click-child-theme.php:557
|
||||
msgid "Theme directory already exists!"
|
||||
msgstr "Directório do tema já existe!"
|
||||
|
||||
#: templates/create_child_form.php:16
|
||||
msgid "Create a Child Theme"
|
||||
msgstr "Criar um tema dependente"
|
||||
|
||||
#: templates/create_child_form.php:18
|
||||
#, php-format
|
||||
msgid ""
|
||||
"Fill out this form to create a child theme based on %s (your current theme)."
|
||||
msgstr ""
|
||||
"Preencha este formulário para criar um tema dependente com base no %s (o seu "
|
||||
"tema actual)."
|
||||
|
||||
#: templates/create_child_form.php:25
|
||||
msgid "Theme Name"
|
||||
msgstr "Nome do tema"
|
||||
|
||||
#: templates/create_child_form.php:28
|
||||
msgid "Give your theme a name."
|
||||
msgstr "Dê um nome ao seu tema."
|
||||
|
||||
#: templates/create_child_form.php:32
|
||||
msgid "Description"
|
||||
msgstr "Descrição"
|
||||
|
||||
#: templates/create_child_form.php:35
|
||||
msgid "Describe your theme."
|
||||
msgstr "Descreva seu tema."
|
||||
|
||||
#: templates/create_child_form.php:39
|
||||
msgid "Author"
|
||||
msgstr "Autor"
|
||||
|
||||
#: templates/create_child_form.php:42
|
||||
msgid "Your name."
|
||||
msgstr "O seu nome."
|
||||
|
||||
#: templates/create_child_form.php:47
|
||||
msgid "Create Child"
|
||||
msgstr "Criar tema dependente"
|
||||
|
||||
#: templates/is_child_already.php:10
|
||||
#, php-format
|
||||
msgid "%s is already a child theme"
|
||||
msgstr "%s já é um tema dependente"
|
||||
|
||||
#: templates/is_child_already.php:14
|
||||
msgid "Child theme needs repair"
|
||||
msgstr "O tema dependente necessita de reparação"
|
||||
|
||||
#: templates/is_child_already.php:15
|
||||
msgid ""
|
||||
"Detected outdated child theme mechanism. Click the button below to attempt a "
|
||||
"one-click repair."
|
||||
msgstr ""
|
||||
"Foi detectado um mecanismo desactualizado de tema dependente. Clique no "
|
||||
"botão abaixo para tentar uma reparação imediata."
|
||||
|
||||
#: templates/is_child_already.php:20
|
||||
msgid "Repair Child Theme"
|
||||
msgstr "Reparar tema dependente"
|
||||
|
||||
#: templates/is_child_already.php:28
|
||||
msgid "Child files"
|
||||
msgstr "Ficheiros do tema dependente"
|
||||
|
||||
#: templates/is_child_already.php:29
|
||||
msgid ""
|
||||
"If you wish to modify the behavior of a template file, select it and click "
|
||||
"the \"Copy Template\" button below."
|
||||
msgstr ""
|
||||
"Se quiser modificar o comportamento de um ficheiro de modelo, seleccione-o e "
|
||||
"clique no botão \"Copiar modelo\" abaixo."
|
||||
|
||||
#: templates/is_child_already.php:35
|
||||
msgid "Template File"
|
||||
msgstr "Ficheiro modelo"
|
||||
|
||||
#: templates/is_child_already.php:48
|
||||
msgid "Copy Template"
|
||||
msgstr "Copiar modelo"
|
||||
|
||||
#: templates/is_child_already.php:55
|
||||
msgid "Screenshot"
|
||||
msgstr "Captura de ecrã"
|
||||
|
||||
#: templates/is_child_already.php:56
|
||||
msgid ""
|
||||
"By default One-Click Child Theme uses the parent theme’s screenshot. You can "
|
||||
"use WordPress.com’s mshot service to replace the current child theme’s "
|
||||
"screenshot with a screenshot of your current web site’s homepage (if "
|
||||
"publicly accessible over the web)."
|
||||
msgstr ""
|
||||
"Por omissão o One-Click Child Theme utiliza a captura de ecrã do tema "
|
||||
"superior. Pode utilizar o serviço mshot do WordPress.com para substituir a "
|
||||
"actual captura de ecrã do tema dependente com uma captura de ecrã da página "
|
||||
"inicial do seu site (se estiver acessível publicamente na internet)."
|
||||
|
||||
#: templates/is_child_already.php:65
|
||||
msgid "No screenshot"
|
||||
msgstr "Sem captura de ecrã"
|
||||
|
||||
#: templates/is_child_already.php:70
|
||||
msgid "Current"
|
||||
msgstr "Actual"
|
||||
|
||||
#: templates/is_child_already.php:76
|
||||
msgid "mShot"
|
||||
msgstr "mShot"
|
||||
|
||||
#: templates/is_child_already.php:81
|
||||
msgid "Replace Screenshot"
|
||||
msgstr "Substituir captura de ecrã"
|
||||
|
||||
#: templates/is_child_already.php:85
|
||||
msgid "Grandchild theme?"
|
||||
msgstr "Tema duplamente dependente?"
|
||||
|
||||
#: templates/is_child_already.php:86
|
||||
msgid ""
|
||||
"WordPress has no formal support for theme grandchildren. No other actions "
|
||||
"currently supported in One Click Child Theme."
|
||||
msgstr ""
|
||||
"O WordPress não tem suporte formal para temas duplamente dependentes. "
|
||||
"Actualmente não são suportadas mais acções pelo One Click Child Theme."
|
||||
|
||||
#~ msgid ""
|
||||
#~ "By default One-Click Child theme uses the parent theme’s screenshot. You "
|
||||
#~ "can use WordPress.com’s mshot service to replace the current child "
|
||||
#~ "theme’s screenshot with a screenshot of your current web site’s homepage "
|
||||
#~ "(if publicly accessible over the web)."
|
||||
#~ msgstr ""
|
||||
#~ "Por omissão o One-Click Child Theme utiliza a captura de ecrã do tema "
|
||||
#~ "superior. Pode utilizar o serviço mshot do WordPress.com para substituir "
|
||||
#~ "a actual captura de ecrã do tema dependente com uma captura de ecrã da "
|
||||
#~ "página inicial do seu site (se estiver acessível publicamente na "
|
||||
#~ "internet)."
|
||||
@@ -0,0 +1,212 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: One-Click Child Theme\n"
|
||||
"POT-Creation-Date: 2015-04-15 14:53-0000\n"
|
||||
"PO-Revision-Date: 2015-04-15 14:53-0000\n"
|
||||
"Last-Translator: Pedro Mendonça <ped.gaspar@gmail.com>\n"
|
||||
"Language-Team: Andy Fragen <andy@thefragens.com>\n"
|
||||
"Language: en_US\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.7.5\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
||||
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
||||
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: one-click-child-theme.php:120
|
||||
#, php-format
|
||||
msgid ""
|
||||
"Theme switched! <a href=\"%s\">Click here to edit the child stylesheet</a>."
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:133
|
||||
#, php-format
|
||||
msgid "Failed to create file: %s"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:140
|
||||
#, php-format
|
||||
msgid "Failed to edit file: %s"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:146
|
||||
msgid "Repaired child theme."
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:150
|
||||
msgid "No template file specified."
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:154
|
||||
#, php-format
|
||||
msgid "Template file %s does not exist in parent theme!"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:161
|
||||
#, php-format
|
||||
msgid "Template file %s already exists in child theme!"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:168
|
||||
#, php-format
|
||||
msgid "Failed to duplicate file %s!"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:175
|
||||
#, php-format
|
||||
msgid "<a href=\"%s\">File %s created!</a>"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:189
|
||||
#, php-format
|
||||
msgid "Failed to delete file %s!"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:196
|
||||
#, php-format
|
||||
msgid "404 File not found at %s!"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:203
|
||||
#, php-format
|
||||
msgid "Unrecognized mimetype at %s!"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:210
|
||||
#, php-format
|
||||
msgid "Failed to create file %s!"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:216
|
||||
msgid "Successfully changed screenshot."
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:233
|
||||
msgid "Make a Child Theme"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:234
|
||||
msgid "Child Theme"
|
||||
msgstr ""
|
||||
|
||||
#: one-click-child-theme.php:557
|
||||
msgid "Theme directory already exists!"
|
||||
msgstr ""
|
||||
|
||||
#: templates/create_child_form.php:16
|
||||
msgid "Create a Child Theme"
|
||||
msgstr ""
|
||||
|
||||
#: templates/create_child_form.php:18
|
||||
#, php-format
|
||||
msgid ""
|
||||
"Fill out this form to create a child theme based on %s (your current theme)."
|
||||
msgstr ""
|
||||
|
||||
#: templates/create_child_form.php:25
|
||||
msgid "Theme Name"
|
||||
msgstr ""
|
||||
|
||||
#: templates/create_child_form.php:28
|
||||
msgid "Give your theme a name."
|
||||
msgstr ""
|
||||
|
||||
#: templates/create_child_form.php:32
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
#: templates/create_child_form.php:35
|
||||
msgid "Describe your theme."
|
||||
msgstr ""
|
||||
|
||||
#: templates/create_child_form.php:39
|
||||
msgid "Author"
|
||||
msgstr ""
|
||||
|
||||
#: templates/create_child_form.php:42
|
||||
msgid "Your name."
|
||||
msgstr ""
|
||||
|
||||
#: templates/create_child_form.php:47
|
||||
msgid "Create Child"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:10
|
||||
#, php-format
|
||||
msgid "%s is already a child theme"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:14
|
||||
msgid "Child theme needs repair"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:15
|
||||
msgid ""
|
||||
"Detected outdated child theme mechanism. Click the button below to attempt a "
|
||||
"one-click repair."
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:20
|
||||
msgid "Repair Child Theme"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:28
|
||||
msgid "Child files"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:29
|
||||
msgid ""
|
||||
"If you wish to modify the behavior of a template file, select it and click "
|
||||
"the \"Copy Template\" button below."
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:35
|
||||
msgid "Template File"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:48
|
||||
msgid "Copy Template"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:55
|
||||
msgid "Screenshot"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:56
|
||||
msgid ""
|
||||
"By default One-Click Child Theme uses the parent theme’s screenshot. You can "
|
||||
"use WordPress.com’s mshot service to replace the current child theme’s "
|
||||
"screenshot with a screenshot of your current web site’s homepage (if "
|
||||
"publicly accessible over the web)."
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:65
|
||||
msgid "No screenshot"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:70
|
||||
msgid "Current"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:76
|
||||
msgid "mShot"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:81
|
||||
msgid "Replace Screenshot"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:85
|
||||
msgid "Grandchild theme?"
|
||||
msgstr ""
|
||||
|
||||
#: templates/is_child_already.php:86
|
||||
msgid ""
|
||||
"WordPress has no formal support for theme grandchildren. No other actions "
|
||||
"currently supported in One Click Child Theme."
|
||||
msgstr ""
|
||||
@@ -0,0 +1,686 @@
|
||||
<?php
|
||||
/*
|
||||
**************************************************************************
|
||||
|
||||
Plugin Name: One-Click Child Theme
|
||||
Plugin URI: http://terrychay.com/wordpress-plugins/one-click-child-theme
|
||||
Version: 1.6
|
||||
Description: Easily child theme any theme from wp-admin wp-admin without going into shell or using FTP.
|
||||
Author: tychay
|
||||
Author URI: http://terrychay.com/
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
Text Domain: one-click-child-theme
|
||||
Domain Path: /languages
|
||||
|
||||
**************************************************************************/
|
||||
/* Copyright 2011-2015 terry chay (email : tychay@php.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2, as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* Performance: One-Click Child Theme is only active in admin page
|
||||
*/
|
||||
if (!is_admin()) { return; }
|
||||
/**
|
||||
* Load textdomain
|
||||
*/
|
||||
function _load_textdomain() {
|
||||
load_plugin_textdomain( 'one-click-child-theme', false, basename(dirname(__FILE__)) . '/languages' );
|
||||
}
|
||||
add_action( 'init', '_load_textdomain' );
|
||||
/**
|
||||
* The namespace for the One-Click Child Theme Plugin
|
||||
*/
|
||||
class OneClickChildTheme {
|
||||
/**
|
||||
* @const string Used for id generation and language text domain.
|
||||
*/
|
||||
const _SLUG = 'one-click-child-theme';
|
||||
/**
|
||||
* Used for loading in files
|
||||
* @var string
|
||||
*/
|
||||
private $_pluginDir = '';
|
||||
/**
|
||||
* This plugin's theme page
|
||||
*/
|
||||
private $_themePageUrl = '';
|
||||
/**
|
||||
* Theme page name (menu slug)
|
||||
* @var string
|
||||
*/
|
||||
private $_menuId = '';
|
||||
/**
|
||||
* action for Create Child form
|
||||
*/
|
||||
private $_createChildFormId = '';
|
||||
/**
|
||||
* action for Repair Child form
|
||||
*/
|
||||
private $_repairChildFormId = '';
|
||||
/**
|
||||
* action for Copy Template form
|
||||
*/
|
||||
private $_copyTemplateFormId = '';
|
||||
/**
|
||||
* action for screenshot generation
|
||||
*/
|
||||
private $_mshotSiteFormId = '';
|
||||
|
||||
public function __construct() {
|
||||
$this->_pluginDir = dirname(__FILE__);
|
||||
$this->_menuId = self::_SLUG . '-page';
|
||||
$this->_themePageUrl = admin_url('themes.php?page='.$this->_menuId);
|
||||
$this->_createChildFormId = self::_SLUG.'-create-child';
|
||||
$this->_repairChildFormId = self::_SLUG.'-repair-child';
|
||||
$this->_copyTemplateFormId = self::_SLUG.'-copy-template';
|
||||
$this->_mshotSiteFormId = self::_SLUG.'-mshot-site';
|
||||
|
||||
// it has to be buried like this or you get an error:
|
||||
// "You do not have sufficient permissions to access this page"
|
||||
add_action( 'admin_menu', array($this,'createAdminMenu') );
|
||||
|
||||
// form handling code
|
||||
add_action( 'admin_post_'.$this->_createChildFormId, array($this,'processCreateForm') );
|
||||
add_action( 'admin_post_'.$this->_repairChildFormId, array($this,'processRepairChildForm') );
|
||||
add_action( 'admin_post_'.$this->_copyTemplateFormId, array($this,'processCopyTemplateForm') );
|
||||
add_action( 'admin_post_'.$this->_mshotSiteFormId, array($this,'processMShotSiteForm') );
|
||||
// TODO: I could also use the $pagenow global, but is it still there?
|
||||
if ( basename($_SERVER['PHP_SELF']) == 'themes.php' && !empty($_REQUEST['occt_error']) ) {
|
||||
add_action( 'admin_notices', array($this,'showErrorNotice'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handle error and update notices for this theme
|
||||
*
|
||||
* There are now four types of notices: success (green), warning (orange), error (red),
|
||||
* and info (blue).
|
||||
*
|
||||
* Put here because there is a redirect between all forms and error notifications and
|
||||
* add_settings_error() only covers options API errors.
|
||||
*/
|
||||
public function showErrorNotice()
|
||||
{
|
||||
switch ($_GET['occt_error']) {
|
||||
case 'child_created': //SUCCESS: child theme created
|
||||
$type = 'updated'; //fade?
|
||||
$msg = sprintf(
|
||||
__('Theme switched! <a href="%s">Click here to edit the child stylesheet</a>.', self::_SLUG),
|
||||
add_query_arg(
|
||||
urlencode_deep(array(
|
||||
'file' => 'style.css',
|
||||
'theme' => get_stylesheet(),
|
||||
)),
|
||||
admin_url('theme-editor.php')
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'create_failed': //ERROR: create file failed (probably due to permissions)
|
||||
$type = 'error';
|
||||
$msg = sprintf(
|
||||
__('Failed to create file: %s', self::_SLUG),
|
||||
esc_html($_GET['filename'])
|
||||
);
|
||||
break;
|
||||
case 'edit_failed': //ERROR: edit file failed (probably do to permissions)
|
||||
$type = 'error';
|
||||
$msg = sprintf(
|
||||
__('Failed to edit file: %s', self::_SLUG),
|
||||
esc_html($_GET['filename'])
|
||||
);
|
||||
break;
|
||||
case 'repair_success': //SUCCESS: repaired child theme
|
||||
$type = 'updated fade';
|
||||
$msg = __('Repaired child theme.', self::_SLUG);
|
||||
break;
|
||||
case 'no_template': //ERROR: template file not specified
|
||||
$type = 'error';
|
||||
$msg = __('No template file specified.', self::_SLUG);
|
||||
case 'missing_template': //ERROR: parent theme doesn't have template
|
||||
$type = 'error';
|
||||
$msg = sprintf(
|
||||
__('Template file %s does not exist in parent theme!', self::_SLUG),
|
||||
esc_html($_GET['filename'])
|
||||
);
|
||||
break;
|
||||
case 'already_template': //ERROR: child theme already has template
|
||||
$type = 'error';
|
||||
$msg = sprintf(
|
||||
__('Template file %s already exists in child theme!', self::_SLUG),
|
||||
esc_html($_GET['filename'])
|
||||
);
|
||||
break;
|
||||
case 'copy_failed': //ERROR: couldn't duplicate file for some reason
|
||||
$type = 'error';
|
||||
$msg = sprintf(
|
||||
__('Failed to duplicate file %s!', self::_SLUG),
|
||||
esc_html($_GET['filename'])
|
||||
);
|
||||
break;
|
||||
case 'copy_success': //SUCCESS: template file created
|
||||
$type = 'updated'; //fade?
|
||||
$msg = sprintf(
|
||||
__('<a href="%s">File %s created!</a>', self::_SLUG),
|
||||
add_query_arg(
|
||||
urlencode_deep(array(
|
||||
'file' => $_GET['filename'],
|
||||
'theme' => get_stylesheet(),
|
||||
)),
|
||||
admin_url('theme-editor.php')
|
||||
),
|
||||
esc_html($_GET['filename'])
|
||||
);
|
||||
break;
|
||||
case 'delete_failed': //ERROR: couldn't delete file for some reason
|
||||
$type = 'error';
|
||||
$msg = sprintf(
|
||||
__('Failed to delete file %s!', self::_SLUG),
|
||||
esc_html($_GET['filename'])
|
||||
);
|
||||
break;
|
||||
case 'mshot_404': //ERROR: couldn't find mshot
|
||||
$type = 'error';
|
||||
$msg = sprintf(
|
||||
__('404 File not found at %s!', self::_SLUG),
|
||||
esc_html($_GET['url'])
|
||||
);
|
||||
break;
|
||||
case 'mshot_mime_wrong': //ERROR: couldn't find mshot
|
||||
$type = 'error';
|
||||
$msg = sprintf(
|
||||
__('Unrecognized mimetype at %s!', self::_SLUG),
|
||||
esc_html($_GET['url'])
|
||||
);
|
||||
break;
|
||||
case 'mshot_nocreate': //ERROR: couldn't find mshot
|
||||
$type = 'error';
|
||||
$msg = sprintf(
|
||||
__('Failed to create file %s!', self::_SLUG),
|
||||
esc_html($_GET['filename'])
|
||||
);
|
||||
break;
|
||||
case 'mshot_success': //SUCCESS: screenshot generated
|
||||
$type = 'updated fade'; //fade?
|
||||
$msg = __('Successfully changed screenshot.', self::_SLUG);
|
||||
break;
|
||||
default: //ERROR: it is a generic error message
|
||||
$type = 'error';
|
||||
$msg = esc_html($_GET['occt_error']);
|
||||
}
|
||||
printf(
|
||||
'<div class="%s"><p>%s</p></div>',
|
||||
$type,
|
||||
$msg
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Adds an admin menu for One Click Child Theme in Appearances
|
||||
*/
|
||||
public function createAdminMenu() {
|
||||
add_theme_page(
|
||||
__('Make a Child Theme', self::_SLUG), //page title
|
||||
__('Child Theme', self::_SLUG), //menu title
|
||||
'install_themes', //capability needed to view
|
||||
$this->_menuId, //menu slug (and page query url)
|
||||
array( $this, 'showThemePage' ) //callback function
|
||||
);
|
||||
}
|
||||
//
|
||||
// SHOW THEME PAGE
|
||||
//
|
||||
/**
|
||||
* Show the theme page which has a form allowing you to child theme
|
||||
* currently selected theme.
|
||||
*
|
||||
*/
|
||||
public function showThemePage()
|
||||
{
|
||||
// Form is processed in the admin_post_* hooks
|
||||
|
||||
// Handle case where current theme is already a child
|
||||
if ( is_child_theme() ) {
|
||||
$this->_showFormAlreadyChild( $this->_child_theme_needs_repair() );
|
||||
return;
|
||||
}
|
||||
|
||||
// Default behavior: We are not a child theme, but interested in creating one.
|
||||
// Grab default values from a form fail
|
||||
$theme_name = ( !empty($_GET['theme_name']) ) ? $_GET['theme_name'] : '';
|
||||
$description = ( !empty($_GET['description']) ) ? $_GET['description'] : '';
|
||||
if ( !empty($_GET['author_name']) ) {
|
||||
$author = $_GET['author_name'];
|
||||
} else {
|
||||
global $current_user;
|
||||
get_currentuserinfo();
|
||||
$author = $current_user->display_name;
|
||||
}
|
||||
// render default behaivor
|
||||
require $this->_pluginDir.'/templates/create_child_form.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the "is child already" template.
|
||||
* @param boolean $child_needs_repair whether or not child theme needs repair
|
||||
* @todo handle grandchildren
|
||||
*/
|
||||
private function _showFormAlreadyChild($child_needs_repair) {
|
||||
// set template parameters
|
||||
$current_theme = wp_get_theme();
|
||||
$child_theme_screenshot_url = ( $screenshot_filename = $this->_scanForScreenshot( get_stylesheet_directory() ) )
|
||||
? get_stylesheet_directory_uri().'/'.$screenshot_filename
|
||||
: '';
|
||||
$mshot_url = $this->_mshotUrl();
|
||||
// Search for template files.
|
||||
// Note: since there can be files like {mimetype}.php, we must assume
|
||||
// that any root level .php files in the template directory are
|
||||
// templates.
|
||||
$template_files = glob ( get_template_directory().'/*.php' );
|
||||
foreach ( $template_files as $index=>$file ) {
|
||||
$template_files[$index] = basename( $file );
|
||||
}
|
||||
// Filter out any files in child already created
|
||||
$child_theme_dir = get_stylesheet_directory();
|
||||
foreach ( $template_files as $index=>$filename ) {
|
||||
if ( file_exists($child_theme_dir.'/'.$filename) ) {
|
||||
unset($template_files[$index]);
|
||||
}
|
||||
}
|
||||
require $this->_pluginDir.'/templates/is_child_already.php';
|
||||
}
|
||||
//
|
||||
// FORM HANDLING
|
||||
//
|
||||
/**
|
||||
* Handle the create child form.
|
||||
*/
|
||||
public function processCreateForm() {
|
||||
check_admin_referer( $this->_createChildFormId . '-verify' );
|
||||
$theme_name = $_POST['theme_name'];
|
||||
$description = ( empty($_POST['description']) )
|
||||
? ''
|
||||
: $_POST['description'];
|
||||
$author_name = ( empty($_POST['author_name']) )
|
||||
? ''
|
||||
: $_POST['author_name'];
|
||||
$result = $this->_make_child_theme( $theme_name, $description, $author_name );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
// should show create child form again
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
$result->get_error_message(),
|
||||
array(
|
||||
'theme_name' => $theme_name,
|
||||
'description' => $description,
|
||||
'author_name' => $author_name,
|
||||
)
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
switch_theme( $result['parent_template'], $result['new_theme'] );
|
||||
// Redirect to themes page on success
|
||||
$this->_redirect(
|
||||
admin_url('themes.php'),
|
||||
'child_created'
|
||||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handle the repair_child_form form.
|
||||
*/
|
||||
public function processRepairChildForm()
|
||||
{
|
||||
check_admin_referer( $this->_repairChildFormId . '-verify' );
|
||||
$child_theme_dir = get_stylesheet_directory();
|
||||
$functions_file = $child_theme_dir.'/functions.php';
|
||||
$style_file = $child_theme_dir.'/style.css';
|
||||
|
||||
// create functions.php if it doesn't exist yet
|
||||
if ( !file_exists($functions_file) ) {
|
||||
if ( !touch($functions_file) ) {
|
||||
// fixing is hopeless if we can't create the file :-(
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'create_failed',
|
||||
array( 'filename' => $functions_file )
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// read in style.css
|
||||
$style_text = file_get_contents( $style_file );
|
||||
// prune out old rules
|
||||
$style_text = preg_replace(
|
||||
'!@import\s+url\(\s?["\']\.\./.*/style.css["\']\s?\);!ims',
|
||||
'',
|
||||
$style_text
|
||||
);
|
||||
$style_text = preg_replace(
|
||||
'!@import\s+url\(\s?["\']'.get_template_directory_uri().'/style.css["\']\s?\);!ims',
|
||||
'',
|
||||
$style_text
|
||||
);
|
||||
if ( file_put_contents( $style_file, $style_text) === false ) {
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'edit_failed',
|
||||
array( 'filename' => $style_file )
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// modify functions.php to prepend new rules
|
||||
$functions_text = file_get_contents( $this->_pluginDir.'/templates/functions.php' );
|
||||
// ^^^ above file has no final carriage return and ending comment so it should
|
||||
// "smash" the starting '<?php' string in any existing functions.php.
|
||||
$functions_text .= file_get_contents( $functions_file );
|
||||
if ( file_put_contents( $functions_file, $functions_text ) === false ) {
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'edit_failed',
|
||||
array( 'filename' => $functions_file )
|
||||
);
|
||||
return;
|
||||
}
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'repair_success'
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Handle the Copy Template form.
|
||||
*/
|
||||
public function processCopyTemplateForm() {
|
||||
check_admin_referer( $this->_copyTemplateFormId . '-verify' );
|
||||
$filename = ( empty($_POST['filename']) )
|
||||
? ''
|
||||
: $_POST['filename'];
|
||||
if ( !$filename ) {
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'no_template'
|
||||
);
|
||||
return;
|
||||
}
|
||||
$child_theme_dir = get_stylesheet_directory();
|
||||
$template_dir = get_template_directory();
|
||||
var_dump('bar');
|
||||
if ( !file_exists($template_dir.'/'.$filename) ) {
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'missing_template',
|
||||
array( 'filename' => $filename )
|
||||
);
|
||||
return;
|
||||
}
|
||||
if ( file_exists($child_theme_dir.'/'.$filename) ) {
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'already_template',
|
||||
array( 'filename' => $filename )
|
||||
);
|
||||
return;
|
||||
}
|
||||
if ( !copy( $template_dir.'/'.$filename, $child_theme_dir.'/'.$filename ) ) {
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'copy_failed',
|
||||
array( 'filename' => $filename )
|
||||
);
|
||||
}
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'copy_success',
|
||||
array( 'filename' => $filename )
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Handle the mshot Screenshot form
|
||||
*/
|
||||
public function processMShotSiteForm()
|
||||
{
|
||||
check_admin_referer( $this->_mshotSiteFormId . '-verify' );
|
||||
|
||||
// delete existing screenshot if it exists
|
||||
$child_theme_dir = get_stylesheet_directory();
|
||||
if ( $screenshot_filename = $this->_scanForScreenshot($child_theme_dir) ) {
|
||||
$screenshot_path = $child_theme_dir.'/'.$screenshot_filename;
|
||||
if ( !unlink($screenshot_path) ) {
|
||||
// most likely a directory problem Fail with an error
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'delete_failed',
|
||||
array( 'filename' => $screenshot_path )
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$mshot_url = $this->_mshotUrl();
|
||||
// Get the mshot
|
||||
$response = wp_remote_get($mshot_url);
|
||||
|
||||
if ( $response['code'] == 404 ) {
|
||||
// The 404 image is gorgeous nowadays, but (if wp.com correctly handled error
|
||||
// codes for image generation) we'd not let them use it as a theme screenshot.
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'mshot_404',
|
||||
array( 'url' => $mshot_url )
|
||||
);
|
||||
}
|
||||
// Should be 'image/jpeg', but let's hedge our bets
|
||||
switch ($response['headers']['content-type']) {
|
||||
case 'image/jpeg':
|
||||
$screenshot_filename = 'screenshot.jpg';
|
||||
break;
|
||||
case 'image/png':
|
||||
$screenshot_filename = 'screenshot.png';
|
||||
break;
|
||||
case 'image/gif':
|
||||
$screenshot_filename = 'screenshot.gif';
|
||||
break;
|
||||
default:
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'mshot_mime_wrong',
|
||||
array( 'url' => $mshot_url )
|
||||
);
|
||||
return;
|
||||
}
|
||||
$screenshot_path = $child_theme_dir.'/'.$screenshot_filename;
|
||||
if ( file_put_contents($screenshot_path, $response['body']) === false ) {
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'mshot_nocreate',
|
||||
array( 'filename' => $screenshot_path )
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_redirect(
|
||||
$this->_themePageUrl,
|
||||
'mshot_success'
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// PRIVATE METHOD
|
||||
//
|
||||
/**
|
||||
* Does the work to make a child theme based on the current theme.
|
||||
*
|
||||
* This currently supports the following files:
|
||||
*
|
||||
* 1. style.css: Follows the rules outlined in {@link http://codex.wordpress.org/Child_Themes the Codex}
|
||||
* 2. functions.php: Followed the updated rules outlined in the Codex. Note
|
||||
* that since WordPress ?.? functions.php hierarchy is automatically
|
||||
* included.
|
||||
* 3. rtl.css: right to left language support, if not avaialble in parent, it
|
||||
* uses TwentyFifteen's rtl
|
||||
* 4. screenshot.png: screenshot if available in the parent
|
||||
*
|
||||
* @author terry chay <tychay@autoamttic.com>
|
||||
* @author Chris Robinson <http://contempographicdesign.com/> (for screenshot support).
|
||||
* @return array|WP_Error If successful, it returns a hash contianing
|
||||
* - new_theme: (directory) name of new theme
|
||||
* - parent_template: (directory) name of parent template
|
||||
* - parent_theme: (directory) name of parent theme
|
||||
* - new_theme_path: full path to the directory cotnaining the new theme
|
||||
* - new_theme_title: the name of the new theme
|
||||
*/
|
||||
private function _make_child_theme( $new_theme_title, $new_theme_description, $new_theme_author ) {
|
||||
$parent_theme_title = get_current_theme();
|
||||
$parent_theme_template = get_template(); //Doesn't play nice with the grandkids
|
||||
$parent_theme_name = get_stylesheet();
|
||||
$parent_theme_dir = get_stylesheet_directory();
|
||||
|
||||
// Turn a theme name into a directory name
|
||||
$new_theme_name = sanitize_title( $new_theme_title );
|
||||
$theme_root = get_theme_root();
|
||||
|
||||
// Validate theme name
|
||||
$new_theme_path = $theme_root.'/'.$new_theme_name;
|
||||
if ( file_exists( $new_theme_path ) ) {
|
||||
return new WP_Error( 'exists', __( 'Theme directory already exists!', self::_SLUG ) );
|
||||
}
|
||||
|
||||
mkdir( $new_theme_path );
|
||||
|
||||
// Make style.css
|
||||
ob_start();
|
||||
require $this->_pluginDir.'/templates/child-theme-css.php';
|
||||
$css = ob_get_clean();
|
||||
file_put_contents( $new_theme_path.'/style.css', $css );
|
||||
|
||||
// "Generate" functions.php
|
||||
copy( $this->_pluginDir.'/templates/functions.php', $new_theme_path.'/functions.php' );
|
||||
|
||||
// RTL support
|
||||
$rtl_theme = ( file_exists( $parent_theme_dir.'/rtl.css' ) )
|
||||
? $parent_theme_name
|
||||
: 'twentyfifteen'; //use the latest default theme rtl file
|
||||
ob_start();
|
||||
require $this->_pluginDir.'/templates/rtl-css.php';
|
||||
$css = ob_get_clean();
|
||||
file_put_contents( $new_theme_path.'/rtl.css', $css );
|
||||
|
||||
// Copy screenshot
|
||||
if ( $screenshot_filename = $this->_scanForScreenshot( $parent_theme_dir ) ) {
|
||||
copy(
|
||||
$parent_theme_dir.'/'.$screenshot_filename,
|
||||
$new_theme_path.'/'.$screenshot_filename
|
||||
);
|
||||
} // removed grandfather screenshot check (use mshot instead, rly)
|
||||
|
||||
// Make child theme an allowed theme (network enable theme)
|
||||
$allowed_themes = get_site_option( 'allowedthemes' );
|
||||
$allowed_themes[ $new_theme_name ] = true;
|
||||
update_site_option( 'allowedthemes', $allowed_themes );
|
||||
|
||||
return array(
|
||||
'parent_template' => $parent_theme_template,
|
||||
'parent_theme' => $parent_theme_name,
|
||||
'new_theme' => $new_theme_name,
|
||||
'new_theme_path' => $new_theme_path,
|
||||
'new_theme_title' => $new_theme_title,
|
||||
);
|
||||
}
|
||||
//
|
||||
// PRIVATE UTILITY FUNCTIONS
|
||||
//
|
||||
/**
|
||||
* Detect if child theme needs repair.
|
||||
*
|
||||
* A child theme needs repair if it is missing a functions.php or the
|
||||
* style.css still has a rule that points to the parent.
|
||||
*/
|
||||
private function _child_theme_needs_repair()
|
||||
{
|
||||
$child_theme_dir = get_stylesheet_directory();
|
||||
if ( !file_exists($child_theme_dir.'/functions.php') ) {
|
||||
return true;
|
||||
}
|
||||
$style_text = file_get_contents( $child_theme_dir.'/style.css' );
|
||||
// look for relative match (dificult to extract parent theme directory
|
||||
// so I'll assume any in this path is parent theme)
|
||||
if ( preg_match(
|
||||
'!@import\s+url\(\s?["\']\.\./.*/style.css["\']\s?\);!ims',
|
||||
$style_text
|
||||
) ) {
|
||||
return true;
|
||||
}
|
||||
// look for absolute match
|
||||
if ( preg_match(
|
||||
'!@import\s+url\(\s?["\']'.get_template_directory_uri().'/style.css["\']\s?\);!ims',
|
||||
$style_text
|
||||
) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Handle error redirects (for admin_notices generated by plugin)
|
||||
*
|
||||
* Note add_query_arg() is written like shit. Here are it's problems:
|
||||
*
|
||||
* 1. doesn't take advantage of built-in parse_url()
|
||||
* 2. uses urlencode_deep() instead of an array_merge and built-in http_build_query()
|
||||
* 3. doesn't urlencode() if $arg[0] is an array.
|
||||
*
|
||||
* The 3rd one is extremely non-intuitive, but fixing it, would break backward
|
||||
* compatibility due to double-escaping. I'm hacking around that. :-(
|
||||
*
|
||||
* @param string $url The (base) url to redirect to, usually admin_url()
|
||||
* @param string $error the error code to use
|
||||
* @param string $args other arguments to add to the query string
|
||||
* @return null
|
||||
*/
|
||||
private function _redirect($url, $error, $args = array()) {
|
||||
$args['occt_error'] = $error;
|
||||
$args = urlencode_deep($args);
|
||||
wp_redirect( add_query_arg( $args, $url ) );
|
||||
}
|
||||
/**
|
||||
* Searches directory for a theme screenshot
|
||||
*
|
||||
* @param string $directory directory to search (a theme directory)
|
||||
* @return string|false 'screenshot.png' (or whatever) or false if there is no screenshot
|
||||
*/
|
||||
private function _scanForScreenshot($directory)
|
||||
{
|
||||
$screenshots = glob( $directory.'/screenshot.{png,jpg,jpeg,gif}', GLOB_BRACE );
|
||||
return (empty($screenshots))
|
||||
? false
|
||||
: basename($screenshots[0]);
|
||||
}
|
||||
/**
|
||||
* Generate mshot of wordpress homepage.
|
||||
*
|
||||
* Recommende image dimensions from https://codex.wordpress.org/Theme_Development#Screenshot
|
||||
* @todo probably won't work correctly in multisite installs
|
||||
* @todo remove debugging code
|
||||
*/
|
||||
private function _mshotUrl()
|
||||
{
|
||||
$scheme = (is_ssl()) ? 'https' : 'http';
|
||||
return $scheme . '://s.wordpress.com/mshots/v1/'. urlencode(get_site_url()) . '?w=880&h=660';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new OneClickChildTheme();
|
||||
// Start this plugin
|
||||
//add_action( 'admin_init', array('OneClickChildTheme','init'), 12 );
|
||||
225
wp-content/plugins/one-click-child-theme/readme.txt
Normal file
225
wp-content/plugins/one-click-child-theme/readme.txt
Normal file
@@ -0,0 +1,225 @@
|
||||
=== One-Click Child Theme ===
|
||||
Contributors: tychay
|
||||
Donate link: http://www.kiva.org/lender/tychay
|
||||
Tags: theme, child theme, child theme creator, child theme creator, CSS, stylesheet, custom theme, customize theme, shared hosting
|
||||
Requires at least: 3.0
|
||||
Tested up to: 4.1.1
|
||||
Stable tag: trunk
|
||||
|
||||
Adds a Theme option to any active theme allowing you to make a child theme.
|
||||
|
||||
== Description ==
|
||||
|
||||
Please visit the [plugin homepage](http://terrychay.com/wordpress-plugins/one-click-child-theme).
|
||||
|
||||
Useful for shared hosts, this allows you to easily create child themes from any
|
||||
theme just by clicking.
|
||||
|
||||
Ever since WordPress 3.0, you shouldn’t directly modify CSS of any downloaded
|
||||
themes because if you update the theme, your changes will be destroyed. Instead, it is recommended that you create a child theme and edit the CSS
|
||||
there so that updates to the parent theme will be inherited instead of destroy
|
||||
your changes.
|
||||
|
||||
The problem many run into is currently the only way to child theme something
|
||||
is edit files on the filesystem. This is non-intuitive for shared-hosting
|
||||
sites with one-click WordPress installs (it usually involves a “shell account”
|
||||
or learning how to use FTP).
|
||||
|
||||
This attempts to get around that issue, by adding a button to the themes page
|
||||
to allow you to child theme the page. (It’s not really one-click, though.)
|
||||
|
||||
Inspired by @janeforshort's and @designsimply's WordCamp SF 2011 talk on CSS
|
||||
theming as requested by @sfgirl for [her blog](http://pintsizedmusings.com/).
|
||||
|
||||
== Installation ==
|
||||
|
||||
###Installing The Plugin###
|
||||
|
||||
Extract all files from the ZIP file, making sure to keep the file structure
|
||||
intact, and then upload it to `/wp-content/plugins/`. Then just visit your
|
||||
admin area and activate the plugin. That's it!
|
||||
|
||||
**See Also:** ["Installing Plugins" article on the WP Codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins)
|
||||
|
||||
###Using the plugin###
|
||||
|
||||
If you have the capability to install themes in your admin, then the themes menu
|
||||
will have a new submenu called "Child Theme". Clicking on this gives you a form
|
||||
that will allow you to create a child theme based on the current active theme.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. To use the plugin, click one of these two palces in the Appearance section of your `wp_admin`
|
||||
2. Fill out this form
|
||||
3. You will see the theme will be successfully child-themed, but will track the parent theme correctly.
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= I already modified my CSS in the existing theme? How do I use One Click Child Theme to fix this? =
|
||||
|
||||
You can wait for the theme to get updated and have it break it, or you can:
|
||||
|
||||
1. Go through the steps for installing and running the plugin above to create a child theme
|
||||
2. Click on the [Appearance > Editor](http://codex.wordpress.org/Appearance_Editor_SubPanel) in your admin dashboard menu (or network admin menu if multi-site).
|
||||
3. Select the parent theme in the drop down on the right, click `Select` and make sure you are editing the file `style.css` (select on the right).
|
||||
4. Copy the changes you made, if you managed to remember them.
|
||||
5. Select the child theme you created to the drop down in the left (you should be editing `style.css`).
|
||||
6. Paste your changes to the end of the file.
|
||||
|
||||
= Your plugin broke my site! =
|
||||
|
||||
I didn't think that's possible, but if so, I want to fix it!
|
||||
|
||||
First, check what really happened. Is your admin console broken, is the
|
||||
theme broken (go to a new window and check your blog). If a theme fails to
|
||||
work and for some reason I didn't catch that error, WordPress should restore
|
||||
the previous theme (or whatever the default theme is) so your actual blog
|
||||
should be okay and recoverable. If for some reason it didn't default to the
|
||||
right theme, go into the Appearance menu and re-enable the parent theme.
|
||||
|
||||
Then go to the [support page](https://wordpress.org/support/plugin/one-click-child-theme),
|
||||
describe what happened (screenshots help too) and anything else and we'll try
|
||||
our best to help you.
|
||||
|
||||
= I can't find this Theme Option button you are alluding to in the documentation? =
|
||||
|
||||
I really need to update the screenshot. It's still there, but the location has
|
||||
changed as WordPress has been upgraded.
|
||||
|
||||
1. Go to the `Appearance` tab
|
||||
2. Click on the Active theme (it should say "Theme Details" when you mouseover)
|
||||
3. An overlay appears. The Theme option button "Child Theme" is there
|
||||
|
||||
= When I go to the Child Theme menu, it says "X is already a child theme" and I can't create a child theme. =
|
||||
|
||||
Making grandchildren of themes is non-trivial, so I disabled the form if it is
|
||||
already a child theme. Instead I offer the ability to repair the Child theme or
|
||||
copy template files from the parent into the child for editing.
|
||||
|
||||
= Can the plugin be deleted after I create a Child Theme with it? =
|
||||
|
||||
Yes. The main purpose of the plugin is fulfilled. Congratulations!
|
||||
(Personally, I'd disable it, instead of delete it.)
|
||||
|
||||
Having said that, there are some things that this plugin help with after your
|
||||
child theme's birth. Think of it as a parenting guide for your new child theme.
|
||||
|
||||
= Features like? =
|
||||
|
||||
* Repair a child theme created in the old style.
|
||||
* Copy templates over from your parent theme into your child theme.
|
||||
* Replace the child theme screenshot with one of your site
|
||||
|
||||
When you have an active child theme, click on `Appearance > Child Theme` to
|
||||
get to these functions.
|
||||
|
||||
= What does the "Repair Child Theme" button do? =
|
||||
|
||||
WordPress changed the [recommended way of handling parent references in child themes](http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme).
|
||||
If this plugin detects your child theme was done in the old style, it shows
|
||||
this button. Clicking on it will make the plugin attempt a repair into the
|
||||
new style.
|
||||
|
||||
= How come the screenshot service just shows a big 404 =
|
||||
|
||||
The most likely scenario is your WordPress `site_url` isn't publicly
|
||||
accessible from the web.
|
||||
|
||||
= What's with the debugging/error code on child theme creation? =
|
||||
|
||||
You have an old version of this plugin, please update to the latest one.
|
||||
|
||||
I wrote this plugin back **during** a talk at WordCamp SF 2011 about CSS
|
||||
Themeing in order to help the person sitting next to me. I just didn't get to
|
||||
some things… for years. Sorry about that! The debugging code didn't affect any
|
||||
behavior — it was a sign of me being lazy and not realizing that the plugin
|
||||
would have tens of thousands of avid users!
|
||||
|
||||
= The theme screenshot service doesn't seem to be working. =
|
||||
|
||||
First of all, is the blog accessible from the public Internet? If not, then
|
||||
that is the problem.
|
||||
|
||||
But sometimes, even then, mshots seems a bit on the slow side. The plugin
|
||||
uses WordPress.com’s mShots service. You know, I worked at Automattic for years
|
||||
on WordPress.com and I still haven't quite figured out mShots. Eventually
|
||||
I've gotten the animated loading GIF to be replaced by a real retina-ready JPEG
|
||||
screenshot of my blog homepage. Trust me, when it works, it works great! But
|
||||
the experience may be a little like trying to get a vending machine to accept
|
||||
a crumpled dollar bill — Americans know what I mean. Suffice it to say that
|
||||
you might have to hit reload a couple times, or just fiddle around a bit.
|
||||
|
||||
= Why should I use your plugin and not [_insert competitor here_](https://wordpress.org/plugins/search.php?q=child+theme) =
|
||||
|
||||
What? People have forked my idea because I left [Automattic](http://automattic.com)
|
||||
for [Wikimedia](http://wikimediafoundation.org/wiki/Home) three years ago?
|
||||
This means war! Other plugins, you're going down! Steel yourself for the
|
||||
pent-up aggression of a pointy-haired boss being kept away from a
|
||||
programming console for years.
|
||||
|
||||
As to why this plugin is the best? OCCT is Coke Classic to every other plugin's
|
||||
[New Coke](http://en.wikipedia.org/wiki/New_Coke). Experience the original
|
||||
plugin taste your parents knew and loved! Plus, I have
|
||||
four-year old screenshots on my theme page, a way cooler plugin icon, and a
|
||||
baby picture of me and my brother on the banner. Also, this plugin strikes
|
||||
the right balance of features, is free (no "pro" version and not even a PayPal
|
||||
link), and (now that I've figured out how to admin the plugin page), I've
|
||||
been adding volunteers to support it. Even if I sucked into the vortex of
|
||||
middle management again (isn't going to happen, that s--t is **EVIL**) this
|
||||
plugin will live forever in the hearts and minds of bloggers everywhere!
|
||||
|
||||
Which reminds me, if you want to help out, we're cool with that. Like WordPress
|
||||
itself, this is a volunteer endeavor. Contact us in the support pages and we'll
|
||||
hook you up!
|
||||
|
||||
== ChangeLog ==
|
||||
|
||||
**Version 1.7**
|
||||
|
||||
* Documentation: FAQ fixes
|
||||
|
||||
**Version 1.6**
|
||||
|
||||
* Feature: Added ability to generate theme screenshots (thanks [@janeforshort/@jenmylo](https://jane.wordpress.com/) for the idea)
|
||||
* Feature: Redirect to theme page on child theme creation
|
||||
* Feature: Successful child theme creation suggests you edit its `style.css` file
|
||||
* Performance: Only run code in admin page
|
||||
* Bug: Added in some missing gettext
|
||||
* Bug: Removed the double errors/updates being displays
|
||||
* Documentation: Make sure description is under 140 characters
|
||||
* Documentation: Screenshots now display
|
||||
* Documentation: Added banner image and plugin icon
|
||||
* Documentation: Other minor tweaks including updated FAQ and license
|
||||
|
||||
**Version 1.5**
|
||||
|
||||
* Feature: Added ability to repair child theme
|
||||
* Feature: Added ability to copy any template file from parent theme (thanks [Michael Rawlings](http://michaelrawlins.co.uk) for the idea)
|
||||
* Design: Upgrade look of form to resemble most admin forms.
|
||||
* Bug Fix: Properly shows a status message on success.
|
||||
* Documentation: Added section for FAQ and Screenshots.
|
||||
* Documentation: Some housecleaning of filesystem structure of plugin
|
||||
|
||||
**Version 1.4**
|
||||
|
||||
* Bug Fix: Modified to account for [changed best practice from using @import to function.php](http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme)
|
||||
|
||||
**Version 1.2**
|
||||
|
||||
* Bug Fix: Remembers to network enable (activate) the theme after creation.
|
||||
* Feature: Added screenshot support (Thanks! Chris Robinson <http://contempographicdesign.com/>)
|
||||
* Bug Fix: WP_Error handling
|
||||
* Documentation: Refactored codebase
|
||||
|
||||
**Version 1.1**
|
||||
|
||||
* Feature: Added RTL support
|
||||
|
||||
**Version 1.0.1**
|
||||
|
||||
* Commenting changes.
|
||||
|
||||
**Version 1.0**
|
||||
|
||||
* Initial release
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Theme Name: <?php echo $new_theme_title, "\n"; ?>
|
||||
Description: <?php echo $new_theme_description, "\n"; ?>
|
||||
Author: <?php echo $new_theme_author, "\n"; ?>
|
||||
Template: <?php echo $parent_theme_template, "\n"; ?>
|
||||
|
||||
(optional values you can add: Theme URI, Author URI, Version, License, License URI, Tags, Text Domain)
|
||||
*/
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Page for showing the child theme creation form. (In the Theme > Child Theme submenu.)
|
||||
*
|
||||
* Local Variables
|
||||
* - $this/self: the OCCT object
|
||||
* - $parent_theme_name: the human-readable name of the parent theme
|
||||
* - $theme_name: form variable (if error)
|
||||
* - $description: form variable (if error)
|
||||
* - $author: form variable
|
||||
* @author terry chay <tychay@php.net>
|
||||
*/
|
||||
?>
|
||||
<div class="wrap">
|
||||
|
||||
<h2><?php esc_html_e('Create a Child Theme', self::_SLUG) ?></h2>
|
||||
|
||||
<div class="copy"><?php printf( __( 'Fill out this form to create a child theme based on %s (your current theme).', self::_SLUG ), $parent_theme_name ); ?></div>
|
||||
|
||||
<form action="admin-post.php" method="post" id="create_child_form">
|
||||
<input type="hidden" name="action" value="<?php echo $this->_createChildFormId; ?>" />
|
||||
<?php wp_nonce_field($this->_createChildFormId.'-verify'); ?>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row"><label for="create_child_theme_name"><?php esc_html_e( 'Theme Name', self::_SLUG ); ?></label></th>
|
||||
<td>
|
||||
<input type="text" name="theme_name" value="<?php esc_attr_e($theme_name); ?>" id="create_child_theme_name" />
|
||||
<p class="description"><?php esc_html_e( 'Give your theme a name.', self::_SLUG ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="create_child_description"><?php esc_html_e( 'Description', 'one-click-child-theme' ); ?></label></th>
|
||||
<td>
|
||||
<textarea name="description" value="<?php echo $description; ?>" rows="2" cols="40" id="create_child_description"><?php esc_html_e($description); ?></textarea>
|
||||
<p class="description"><?php esc_html_e( 'Describe your theme.', self::_SLUG ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="create_child_author_name"><?php esc_html_e( 'Author', self::_SLUG ); ?></label></th>
|
||||
<td>
|
||||
<input name="author_name" value="<?php esc_attr_e($author); ?>" id="create_child_author_name" />
|
||||
<p class="description"><?php esc_html_e( 'Your name.', self::_SLUG ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="submit">
|
||||
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Create Child', self::_SLUG ); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
//
|
||||
// Recommended way to include parent theme styles.
|
||||
// (Please see http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme)
|
||||
//
|
||||
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
|
||||
function theme_enqueue_styles() {
|
||||
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')
|
||||
);
|
||||
}
|
||||
//
|
||||
// Your code goes below
|
||||
//
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Page for showing the child theme creation form. (In the Theme > Child Theme submenu.)
|
||||
*
|
||||
* @author terry chay <tychay@php.net>
|
||||
*/
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2><?php esc_html_e( sprintf( __('%s is already a child theme', self::_SLUG), $current_theme->Name ) ); ?></h2>
|
||||
<?php
|
||||
if ( $child_needs_repair ) :
|
||||
?>
|
||||
<h3><?php esc_html_e('Child theme needs repair', self::_SLUG) ?></h3>
|
||||
<div class="copy"><?php esc_html_e( 'Detected outdated child theme mechanism. Click the button below to attempt a one-click repair.', self::_SLUG ); ?></div>
|
||||
<form action="admin-post.php" method="post" id="repair_child_form">
|
||||
<input type="hidden" name="action" value="<?php echo $this->_repairChildFormId; ?>" />
|
||||
<?php wp_nonce_field($this->_repairChildFormId.'-verify'); ?>
|
||||
<p class="submit">
|
||||
<input type="submit" class="button button-primary" value="<?php esc_html_e( 'Repair Child Theme', self::_SLUG ); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
if ( !empty($template_files) ) :
|
||||
?>
|
||||
<h3><?php esc_html_e('Child files',self::_SLUG) ?></h3>
|
||||
<div class="copy"><?php esc_html_e( 'If you wish to modify the behavior of a template file, select it and click the "Copy Template" button below.', self::_SLUG ); ?></div>
|
||||
<form action="admin-post.php" method="post" id="copy_template_file_form">
|
||||
<input type="hidden" name="action" value="<?php echo $this->_copyTemplateFormId; ?>" />
|
||||
<?php wp_nonce_field($this->_copyTemplateFormId.'-verify'); ?>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row"><label for="copy_template_file_name"><?php esc_html_e( 'Template File', self::_SLUG ); ?></label></th>
|
||||
<td><select name="filename" id="copy_template_file_name">
|
||||
<?php
|
||||
foreach ($template_files as $filename) :
|
||||
?>
|
||||
<option value="<?php esc_attr_e($filename); ?>"><?php esc_html_e($filename) ?></option>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="submit">
|
||||
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Copy Template', self::_SLUG ); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
<h3><?php esc_html_e('Screenshot',self::_SLUG) ?></h3>
|
||||
<div class="copy"><?php esc_html_e( 'By default One-Click Child Theme uses the parent theme’s screenshot. You can use WordPress.com’s mshot service to replace the current child theme’s screenshot with a screenshot of your current web site’s homepage (if publicly accessible over the web).', self::_SLUG ); ?></div>
|
||||
<form action="admin-post.php" method="post" id="mshot_homepage_form">
|
||||
<input type="hidden" name="action" value="<?php echo $this->_mshotSiteFormId; ?>" />
|
||||
<?php wp_nonce_field($this->_mshotSiteFormId.'-verify'); ?>
|
||||
<div class="theme-browser">
|
||||
<div class="theme">
|
||||
<?php if ($child_theme_screenshot_url) : ?>
|
||||
<div class="theme-screenshot">
|
||||
<img src="<?php echo $child_theme_screenshot_url ?>" />
|
||||
<p><?php esc_html_e('No screenshot', self::_SLUG); ?></p>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="theme-screenshot blank"></div>
|
||||
<?php endif; ?>
|
||||
<div class="theme-name"><?php esc_html_e('Current', self::_SLUG); ?></div>
|
||||
</div>
|
||||
<div class="theme">
|
||||
<div class="theme-screenshot">
|
||||
<img src="<?php echo $mshot_url ?>" />
|
||||
</div>
|
||||
<div class="theme-name"><?php esc_html_e('mShot', self::_SLUG); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<br clear="all" />
|
||||
<p class="submit">
|
||||
<input type="submit" class="button button-primary" value="<?php esc_html_e( 'Replace Screenshot', self::_SLUG ); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<h3><?php esc_html_e('Grandchild theme?',self::_SLUG) ?></h3>
|
||||
<div class="copy"><?php esc_html_e( 'WordPress has no formal support for theme grandchildren. No other actions currently supported in One Click Child Theme.', self::_SLUG ); ?></div>
|
||||
</div>
|
||||
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
Theme Name: <?php echo $new_theme_title, "\n"; ?>
|
||||
Template: <?php echo $parent_template_name, "\n"; ?>
|
||||
|
||||
Right to Left text support.
|
||||
*/
|
||||
@import url("../<?php echo $rtl_theme; ?>/rtl.css");
|
||||
Reference in New Issue
Block a user