Basic WP tools for installs and maintenance
This commit is contained in:
parent
c6348352a2
commit
0e04b179c2
429
ConfigSetting.php
Normal file
429
ConfigSetting.php
Normal file
@ -0,0 +1,429 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
+--------------------------------------------------------------------+
|
||||||
|
| Copyright CiviCRM LLC. All rights reserved. |
|
||||||
|
| |
|
||||||
|
| This work is published under the GNU AGPLv3 license with some |
|
||||||
|
| permitted exceptions and without any warranty. For full license |
|
||||||
|
| and copyright information, see https://civicrm.org/licensing |
|
||||||
|
+--------------------------------------------------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package CRM
|
||||||
|
* @copyright CiviCRM LLC https://civicrm.org/licensing
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File contains functions used in civicrm configuration.
|
||||||
|
*/
|
||||||
|
class CRM_Core_BAO_ConfigSetting {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create civicrm settings. This is the same as add but it clears the cache and
|
||||||
|
* reloads the config object
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* Associated array of civicrm variables.
|
||||||
|
*/
|
||||||
|
public static function create($params) {
|
||||||
|
self::add($params);
|
||||||
|
$cache = CRM_Utils_Cache::singleton();
|
||||||
|
$cache->delete('CRM_Core_Config');
|
||||||
|
$cache->delete('CRM_Core_Config' . CRM_Core_Config::domainID());
|
||||||
|
$config = CRM_Core_Config::singleton(TRUE, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add civicrm settings.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* Associated array of civicrm variables.
|
||||||
|
* @deprecated
|
||||||
|
* This method was historically used to access civicrm_domain.config_backend.
|
||||||
|
* However, that has been fully replaced by the settings system since v4.7.
|
||||||
|
*/
|
||||||
|
public static function add(&$params) {
|
||||||
|
$domain = new CRM_Core_DAO_Domain();
|
||||||
|
$domain->id = CRM_Core_Config::domainID();
|
||||||
|
$domain->find(TRUE);
|
||||||
|
if ($domain->config_backend) {
|
||||||
|
$params = array_merge(unserialize($domain->config_backend), $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = CRM_Core_BAO_ConfigSetting::filterSkipVars($params);
|
||||||
|
|
||||||
|
// also skip all Dir Params, we dont need to store those in the DB!
|
||||||
|
foreach ($params as $name => $val) {
|
||||||
|
if (substr($name, -3) == 'Dir') {
|
||||||
|
unset($params[$name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$domain->config_backend = serialize($params);
|
||||||
|
$domain->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the settings values from db.
|
||||||
|
*
|
||||||
|
* @param $defaults
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @deprecated
|
||||||
|
* This method was historically used to access civicrm_domain.config_backend.
|
||||||
|
* However, that has been fully replaced by the settings system since v4.7.
|
||||||
|
*/
|
||||||
|
public static function retrieve(&$defaults) {
|
||||||
|
$domain = new CRM_Core_DAO_Domain();
|
||||||
|
$isUpgrade = CRM_Core_Config::isUpgradeMode();
|
||||||
|
|
||||||
|
//we are initializing config, really can't use, CRM-7863
|
||||||
|
$urlVar = 'q';
|
||||||
|
if (defined('CIVICRM_UF') && CIVICRM_UF == 'Joomla') {
|
||||||
|
$urlVar = 'task';
|
||||||
|
}
|
||||||
|
|
||||||
|
$hasBackend = CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_domain', 'config_backend');
|
||||||
|
if ($isUpgrade && $hasBackend) {
|
||||||
|
$domain->selectAdd('config_backend');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$domain->selectAdd('locales');
|
||||||
|
}
|
||||||
|
|
||||||
|
$domain->id = CRM_Core_Config::domainID();
|
||||||
|
$domain->find(TRUE);
|
||||||
|
if ($hasBackend && $domain->config_backend) {
|
||||||
|
// This whole branch can probably be removed; the transitional loading
|
||||||
|
// is in SettingBag::loadValues(). Moreover, since 4.7.alpha1 dropped
|
||||||
|
// the column, anyone calling ::retrieve() has likely not gotten any data.
|
||||||
|
$defaults = unserialize($domain->config_backend);
|
||||||
|
if ($defaults === FALSE || !is_array($defaults)) {
|
||||||
|
$defaults = [];
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$skipVars = self::skipVars();
|
||||||
|
foreach ($skipVars as $skip) {
|
||||||
|
if (array_key_exists($skip, $defaults)) {
|
||||||
|
unset($defaults[$skip]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$isUpgrade) {
|
||||||
|
CRM_Core_BAO_ConfigSetting::applyLocale(Civi::settings($domain->id), $domain->locales);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluate locale preferences and activate a chosen locale by
|
||||||
|
* updating session+global variables.
|
||||||
|
*
|
||||||
|
* @param \Civi\Core\SettingsBag $settings
|
||||||
|
* @param string $activatedLocales
|
||||||
|
* Imploded list of locales which are supported in the DB.
|
||||||
|
*/
|
||||||
|
public static function applyLocale($settings, $activatedLocales) {
|
||||||
|
// are we in a multi-language setup?
|
||||||
|
$multiLang = (bool) $activatedLocales;
|
||||||
|
|
||||||
|
// set the current language
|
||||||
|
$chosenLocale = NULL;
|
||||||
|
|
||||||
|
$session = CRM_Core_Session::singleton();
|
||||||
|
|
||||||
|
$permittedLanguages = CRM_Core_I18n::uiLanguages(TRUE);
|
||||||
|
|
||||||
|
// The locale to be used can come from various places:
|
||||||
|
// - the request (url)
|
||||||
|
// - the session
|
||||||
|
// - civicrm_uf_match
|
||||||
|
// - inherited from the CMS
|
||||||
|
// Only look at this if there is actually a choice of permitted languages
|
||||||
|
if (count($permittedLanguages) >= 2) {
|
||||||
|
$requestLocale = CRM_Utils_Request::retrieve('lcMessages', 'String');
|
||||||
|
if (in_array($requestLocale, $permittedLanguages)) {
|
||||||
|
$chosenLocale = $requestLocale;
|
||||||
|
|
||||||
|
//CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
|
||||||
|
// Ed: This doesn't sound good.
|
||||||
|
// Civi::cache('navigation')->flush();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$requestLocale = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$requestLocale) {
|
||||||
|
$sessionLocale = $session->get('lcMessages');
|
||||||
|
if (in_array($sessionLocale, $permittedLanguages)) {
|
||||||
|
$chosenLocale = $sessionLocale;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sessionLocale = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($requestLocale) {
|
||||||
|
$ufm = new CRM_Core_DAO_UFMatch();
|
||||||
|
$ufm->contact_id = $session->get('userID');
|
||||||
|
if ($ufm->find(TRUE)) {
|
||||||
|
$ufm->language = $chosenLocale;
|
||||||
|
$ufm->save();
|
||||||
|
}
|
||||||
|
$session->set('lcMessages', $chosenLocale);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$chosenLocale and $session->get('userID')) {
|
||||||
|
$ufm = new CRM_Core_DAO_UFMatch();
|
||||||
|
$ufm->contact_id = $session->get('userID');
|
||||||
|
if ($ufm->find(TRUE) &&
|
||||||
|
in_array($ufm->language, $permittedLanguages)
|
||||||
|
) {
|
||||||
|
$chosenLocale = $ufm->language;
|
||||||
|
}
|
||||||
|
$session->set('lcMessages', $chosenLocale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
global $dbLocale;
|
||||||
|
|
||||||
|
// try to inherit the language from the hosting CMS
|
||||||
|
// If the language is specified in the session (ie. via lcMessages) we still allow it to be overridden.
|
||||||
|
if ($settings->get('inheritLocale') && empty($sessionLocale)) {
|
||||||
|
// FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
|
||||||
|
$lcMessages = $settings->get('lcMessages');
|
||||||
|
$dbLocale = $multiLang && $lcMessages ? "_{$lcMessages}" : '';
|
||||||
|
$chosenLocale = CRM_Utils_System::getUFLocale();
|
||||||
|
if ($activatedLocales and !in_array($chosenLocale, explode(CRM_Core_DAO::VALUE_SEPARATOR, $activatedLocales))) {
|
||||||
|
$chosenLocale = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($chosenLocale)) {
|
||||||
|
//CRM-11993 - if a single-lang site, use default
|
||||||
|
$chosenLocale = $settings->get('lcMessages');
|
||||||
|
}
|
||||||
|
|
||||||
|
// set suffix for table names - use views if more than one language
|
||||||
|
$dbLocale = $multiLang && $chosenLocale ? "_{$chosenLocale}" : '';
|
||||||
|
|
||||||
|
// FIXME: an ugly hack to fix CRM-4041
|
||||||
|
global $tsLocale;
|
||||||
|
$tsLocale = $chosenLocale;
|
||||||
|
|
||||||
|
// FIXME: as bad aplace as any to fix CRM-5428
|
||||||
|
// (to be moved to a sane location along with the above)
|
||||||
|
if (function_exists('mb_internal_encoding')) {
|
||||||
|
mb_internal_encoding('UTF-8');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $defaultValues
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function doSiteMove($defaultValues = []) {
|
||||||
|
$moveStatus = ts('Beginning site move process...') . '<br />';
|
||||||
|
$settings = Civi::settings();
|
||||||
|
|
||||||
|
foreach (array_merge(self::getPathSettings(), self::getUrlSettings()) as $key) {
|
||||||
|
$value = $settings->get($key);
|
||||||
|
if ($value && $value != $settings->getDefault($key)) {
|
||||||
|
if ($settings->getMandatory($key) === NULL) {
|
||||||
|
$settings->revert($key);
|
||||||
|
$moveStatus .= ts("WARNING: The setting (%1) has been reverted.", [
|
||||||
|
1 => $key,
|
||||||
|
]);
|
||||||
|
$moveStatus .= '<br />';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$moveStatus .= ts("WARNING: The setting (%1) is overridden and could not be reverted.", [
|
||||||
|
1 => $key,
|
||||||
|
]);
|
||||||
|
$moveStatus .= '<br />';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = CRM_Core_Config::singleton();
|
||||||
|
|
||||||
|
// clear the template_c and upload directory also
|
||||||
|
$config->cleanup(3, TRUE);
|
||||||
|
$moveStatus .= ts('Template cache and upload directory have been cleared.') . '<br />';
|
||||||
|
|
||||||
|
// clear all caches
|
||||||
|
CRM_Core_Config::clearDBCache();
|
||||||
|
Civi::cache('session')->clear();
|
||||||
|
$moveStatus .= ts('Database cache tables cleared.') . '<br />';
|
||||||
|
|
||||||
|
$resetSessionTable = CRM_Utils_Request::retrieve('resetSessionTable',
|
||||||
|
'Boolean',
|
||||||
|
CRM_Core_DAO::$_nullArray,
|
||||||
|
FALSE,
|
||||||
|
FALSE
|
||||||
|
);
|
||||||
|
if ($config->userSystem->is_drupal &&
|
||||||
|
$resetSessionTable
|
||||||
|
) {
|
||||||
|
db_query("DELETE FROM {sessions} WHERE 1");
|
||||||
|
$moveStatus .= ts('Drupal session table cleared.') . '<br />';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$session = CRM_Core_Session::singleton();
|
||||||
|
$session->reset(2);
|
||||||
|
$moveStatus .= ts('Session has been reset.') . '<br />';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $moveStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a componentName and enables it in the config.
|
||||||
|
* Primarily used during unit testing
|
||||||
|
*
|
||||||
|
* @param string $componentName
|
||||||
|
* Name of the component to be enabled, needs to be valid.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
* true if valid component name and enabling succeeds, else false
|
||||||
|
*/
|
||||||
|
public static function enableComponent($componentName) {
|
||||||
|
$config = CRM_Core_Config::singleton();
|
||||||
|
if (in_array($componentName, $config->enableComponents)) {
|
||||||
|
// component is already enabled
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return if component does not exist
|
||||||
|
if (!array_key_exists($componentName, CRM_Core_Component::getComponents())) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get enabled-components from DB and add to the list
|
||||||
|
$enabledComponents = Civi::settings()->get('enable_components');
|
||||||
|
$enabledComponents[] = $componentName;
|
||||||
|
|
||||||
|
self::setEnabledComponents($enabledComponents);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable specified component.
|
||||||
|
*
|
||||||
|
* @param string $componentName
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function disableComponent($componentName) {
|
||||||
|
$config = CRM_Core_Config::singleton();
|
||||||
|
if (!in_array($componentName, $config->enableComponents) ||
|
||||||
|
!array_key_exists($componentName, CRM_Core_Component::getComponents())
|
||||||
|
) {
|
||||||
|
// Post-condition is satisfied.
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get enabled-components from DB and add to the list
|
||||||
|
$enabledComponents = Civi::settings()->get('enable_components');
|
||||||
|
$enabledComponents = array_diff($enabledComponents, [$componentName]);
|
||||||
|
|
||||||
|
self::setEnabledComponents($enabledComponents);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set enabled components.
|
||||||
|
*
|
||||||
|
* @param array $enabledComponents
|
||||||
|
*/
|
||||||
|
public static function setEnabledComponents($enabledComponents) {
|
||||||
|
// fix the config object. update db.
|
||||||
|
Civi::settings()->set('enable_components', $enabledComponents);
|
||||||
|
|
||||||
|
// also force reset of component array
|
||||||
|
CRM_Core_Component::getEnabledComponents(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function skipVars() {
|
||||||
|
return [
|
||||||
|
'dsn',
|
||||||
|
'templateCompileDir',
|
||||||
|
'userFrameworkDSN',
|
||||||
|
'userFramework',
|
||||||
|
'userFrameworkBaseURL',
|
||||||
|
'userFrameworkClass',
|
||||||
|
'userHookClass',
|
||||||
|
'userPermissionClass',
|
||||||
|
'userPermissionTemp',
|
||||||
|
'userFrameworkURLVar',
|
||||||
|
'userFrameworkVersion',
|
||||||
|
'newBaseURL',
|
||||||
|
'newBaseDir',
|
||||||
|
'newSiteName',
|
||||||
|
'configAndLogDir',
|
||||||
|
'qfKey',
|
||||||
|
'gettextResourceDir',
|
||||||
|
'cleanURL',
|
||||||
|
'entryURL',
|
||||||
|
'locale_custom_strings',
|
||||||
|
'localeCustomStrings',
|
||||||
|
'autocompleteContactSearch',
|
||||||
|
'autocompleteContactReference',
|
||||||
|
'checksumTimeout',
|
||||||
|
'checksum_timeout',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $params
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function filterSkipVars($params) {
|
||||||
|
$skipVars = self::skipVars();
|
||||||
|
foreach ($skipVars as $var) {
|
||||||
|
unset($params[$var]);
|
||||||
|
}
|
||||||
|
foreach (array_keys($params) as $key) {
|
||||||
|
if (preg_match('/^_qf_/', $key)) {
|
||||||
|
unset($params[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function getUrlSettings() {
|
||||||
|
return [
|
||||||
|
'userFrameworkResourceURL',
|
||||||
|
'imageUploadURL',
|
||||||
|
'customCSSURL',
|
||||||
|
'extensionsURL',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function getPathSettings() {
|
||||||
|
return [
|
||||||
|
'uploadDir',
|
||||||
|
'imageUploadDir',
|
||||||
|
'customFileUploadDir',
|
||||||
|
'customTemplateDir',
|
||||||
|
'customPHPPathDir',
|
||||||
|
'extensionsDir',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
# src : https://gist.github.com/rjekic/2d04423bd167f8e7afd26f8982609378
|
|
||||||
|
|
||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
clear
|
clear
|
||||||
echo "============================================"
|
echo "============================================"
|
||||||
echo "WordPress Install Script"
|
echo "WordPress Install Script"
|
||||||
echo "============================================"
|
echo "============================================"
|
||||||
|
|
||||||
|
echo "Don't forget to ensure that the database has remote access for this server!"
|
||||||
|
|
||||||
# Gathering database login credentials from user input
|
# Gathering database login credentials from user input
|
||||||
read -p "Database Host: " dbhost
|
read -p "Database Host: " dbhost
|
||||||
read -p "Database Name: " dbname
|
read -p "Database Name: " dbname
|
||||||
@ -111,7 +111,7 @@ else
|
|||||||
|
|
||||||
# create uploads folder and set permissions
|
# create uploads folder and set permissions
|
||||||
mkdir wp-content/uploads
|
mkdir wp-content/uploads
|
||||||
chmod 775 wp-content/uploads
|
chmod 755 wp-content/uploads
|
||||||
echo "Cleaning..."
|
echo "Cleaning..."
|
||||||
# remove zip file
|
# remove zip file
|
||||||
rm latest.tar.gz
|
rm latest.tar.gz
|
||||||
@ -120,7 +120,48 @@ else
|
|||||||
echo "========================="
|
echo "========================="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wp option update permalink_structure '/%postname%/'
|
||||||
|
wp option update default_ping_status 'closed'
|
||||||
|
wp option update default_pingback_flag '0'
|
||||||
|
|
||||||
|
# Install and activate defaults plugins
|
||||||
|
wp plugin --activate
|
||||||
|
|
||||||
|
# Install defaults plugins
|
||||||
|
plugin_list="email-address-encoder connect-polylang-elementor polylang wordfence elementor wordpress-seo acf-openstreetmap-field acf-image-aspect-ratio-crop advanced-custom-fields options-page-admin-for-acf acf-frontend-form-element acf-extended classic-editor"
|
||||||
|
for i in $plugin_list; do #Set parameter of the menu options.
|
||||||
|
read -p "Install $i? (y/n): " install_plugin
|
||||||
|
if [ "$install_plugin" == y ] ; then
|
||||||
|
plugin_install_list="$plugin_install_list $i";
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
wp plugin install $plugin_install_list
|
||||||
|
|
||||||
|
# Update plugins
|
||||||
|
wp plugin update --all
|
||||||
|
|
||||||
# Themes
|
# Themes
|
||||||
#wget --user username --ask-password -O path/to/output.zip https://bitbucket.org/path/to/file.zip
|
wp theme install hello-elementor --activate
|
||||||
#wp theme install https://github.com/Automattic/_s/archive/master.zip --activate
|
wp scaffold child-theme hello-elementor-child --parent_theme=hello-elementor
|
||||||
#wp scaffold child-theme sample-theme --parent_theme=twentysixteen
|
wp theme activate hello-elementor-child
|
||||||
|
|
||||||
|
|
||||||
|
# Other plugins to transfer
|
||||||
|
# FG Drupal to WordPress
|
||||||
|
# ACF PRO
|
||||||
|
# Elementor Pro
|
||||||
|
# Civicrm !! At the right version in case of migration from drupal !!
|
||||||
|
# My_basic utility plugin rename to project specific plugin
|
||||||
|
# civicrm_wp_media
|
||||||
|
# toggle-aid???? test acf-frontend-form-element
|
||||||
|
#
|
||||||
|
# https://download.civicrm.org/latest/
|
||||||
|
# https://download.civicrm.org/latest/civicrm-STABLE-wordpress.zip
|
||||||
|
# https://download.civicrm.org/latest/civicrm-STABLE-l10n.tar.gz
|
||||||
|
# https://download.civicrm.org/civicrm-5.41.1-wordpress.zip
|
||||||
|
# wget https://download.civicrm.org/civicrm-x.x.x-wordpress.zip
|
||||||
|
# https://download.civicrm.org/civicrm-5.41.1-l10n.tar.gz
|
||||||
|
# cd /var/www/wordpress/wp-content/plugins
|
40
eo-import-venues/css/style.css
Normal file
40
eo-import-venues/css/style.css
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*Colours
|
||||||
|
|
||||||
|
#94bbd7
|
||||||
|
#fcd99c
|
||||||
|
#f9b53d
|
||||||
|
#a37429
|
||||||
|
#005ea0
|
||||||
|
#ee201c
|
||||||
|
#45a3a3
|
||||||
|
#98141B
|
||||||
|
|
||||||
|
|
||||||
|
Textes
|
||||||
|
--e-global-color-primary: #000000;
|
||||||
|
--e-global-color-secondary: #54595F;
|
||||||
|
--e-global-color-text: #7A7A7A;
|
||||||
|
--e-global-color-accent: #981914;
|
||||||
|
#566d7d
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* MEDIA START */
|
||||||
|
@media all and (max-width: 1400px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 1200px) {
|
||||||
|
}
|
||||||
|
@media all and (max-width: 992px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 768px) {
|
||||||
|
}
|
||||||
|
@media all and (max-width: 600px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 480px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 360px) {
|
||||||
|
}
|
121
eo-import-venues/eo-import-venues.php
Normal file
121
eo-import-venues/eo-import-venues.php
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: EO import venues
|
||||||
|
Description: Import venues for event organiser...
|
||||||
|
see : https://gist.github.com/stephenharris/00a6a601b274b38a59cc82c146a95688
|
||||||
|
Add options page with ACF with file field and button.
|
||||||
|
Version: 0.1
|
||||||
|
License: GPL
|
||||||
|
Author: Richard Turner
|
||||||
|
Author URI: yoururl
|
||||||
|
*/
|
||||||
|
|
||||||
|
function pgm_enqueue_styles(){
|
||||||
|
$template_url = get_template_directory_uri();
|
||||||
|
$plugin_url = plugin_dir_url( __FILE__ );
|
||||||
|
wp_register_style( 'eoiv-style-css', $plugin_url.'css/style.css', false, NULL, 'all');
|
||||||
|
wp_enqueue_style( 'eoiv-style-css' );
|
||||||
|
wp_register_script('eoiv-custom-script', $plugin_url . 'js/custom-script.js', array('jquery'), null, true);
|
||||||
|
wp_enqueue_script('eoiv-custom-script');
|
||||||
|
|
||||||
|
}
|
||||||
|
add_action( 'wp_enqueue_scripts', 'pgm_enqueue_styles' );
|
||||||
|
|
||||||
|
add_action('acfe/fields/button/name=importer_les_venues', 'acf_import_venues_button_ajax', 10, 2);
|
||||||
|
function acf_import_venues_button_ajax($field, $post_id){
|
||||||
|
|
||||||
|
$column_map = array(
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'address',
|
||||||
|
'city',
|
||||||
|
'state',
|
||||||
|
'postcode',
|
||||||
|
'country',
|
||||||
|
'latitude',
|
||||||
|
'longtitude',
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
[0] => Fête Romane - Wolubilis
|
||||||
|
[1] => http://www.wolubilis.be/fr/la_saison/2013/theatre-danse-musique-cirque_12-13/ds_%E2%80%93_you_can_ne
|
||||||
|
[2] =>
|
||||||
|
[3] => Brussels
|
||||||
|
[4] => Belgiuem
|
||||||
|
[5] =>
|
||||||
|
[6] =>
|
||||||
|
[7] =>
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
//TODO tab/semicolon delimiter!
|
||||||
|
|
||||||
|
$file_ID = $_POST['acf']['field_6231b2205f346'];
|
||||||
|
$tmp = "";
|
||||||
|
$file = get_attached_file($file_ID);
|
||||||
|
// $tmp .= print_r($file,1);
|
||||||
|
// error_log(__LINE__." ".$tmp);
|
||||||
|
if($file == ""){
|
||||||
|
wp_send_json_success("Error File is Empty file_ID:".$file_ID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $csvFile = file($file);
|
||||||
|
$csvFile = fopen($file, 'r');
|
||||||
|
$i = 0;
|
||||||
|
$count_adjusted = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while (($row = fgetcsv($csvFile)) !== false) {
|
||||||
|
// $tmp .= print_r($row,1);
|
||||||
|
// $tmp .= " 1st\n";
|
||||||
|
// $tmp .= print_r(utf8_encode($row),1);
|
||||||
|
// wp_send_json_success("End of Function:".$tmp."\n");
|
||||||
|
if(empty($row)){
|
||||||
|
wp_send_json_success("Error! File is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$venue['name'] = $row[0];
|
||||||
|
$venue['description'] = $row[1];
|
||||||
|
$venue['address'] = $row[2];
|
||||||
|
$venue['city'] = $row[3];
|
||||||
|
$venue['state'] = $row[4];
|
||||||
|
$venue['postcode'] = $row[5];
|
||||||
|
$venue['country'] = $row[6];
|
||||||
|
$venue['latitude'] = $row[7];
|
||||||
|
$venue['longtitude'] = $row[8];
|
||||||
|
|
||||||
|
$return = eo_insert_venue( $venue['name'], $venue );
|
||||||
|
|
||||||
|
// if(is_wp_error( $return )){
|
||||||
|
// $tmp .= print_r($return,1);
|
||||||
|
// wp_send_json_success("End of Function:".$tmp."\n");
|
||||||
|
// return;
|
||||||
|
// }else{
|
||||||
|
// $tmp .= $return."\n";
|
||||||
|
// }
|
||||||
|
$tmp .= print_r($return,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// $tmp .= print_r($return,1);
|
||||||
|
wp_send_json_success("End of Function:".$tmp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action('acf/input/admin_enqueue_scripts', 'acf_admin_enqueue_scripts');
|
||||||
|
function acf_admin_enqueue_scripts() {
|
||||||
|
$plugin_url = plugin_dir_url( __FILE__ );
|
||||||
|
// wp_enqueue_style( 'nevicata-acf-input-css', get_stylesheet_directory_uri() . '/css/nevicata-acf-input.css', false, '1.0.0' );
|
||||||
|
wp_enqueue_script( 'eoiv-acf-input-js', $plugin_url . 'js/eoiv-acf-input.js', false, '1.0.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
2
eo-import-venues/js/custom-script.js
Normal file
2
eo-import-venues/js/custom-script.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
jQuery(document).ready(function($) {
|
||||||
|
});
|
88
eo-import-venues/js/eoiv-acf-input.js
Normal file
88
eo-import-venues/js/eoiv-acf-input.js
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
jQuery(document).ready(function($) {
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Button: Ajax Data
|
||||||
|
*
|
||||||
|
* @Json data Ajax data
|
||||||
|
* @jQuery $el jQuery field element
|
||||||
|
*/
|
||||||
|
|
||||||
|
// filter('acfe/fields/button/data', data, $el);
|
||||||
|
// filter('acfe/fields/button/data/name=importer', data, $el);
|
||||||
|
// filter('acfe/fields/button/data/key=field_6213688a5f49e', data, $el);
|
||||||
|
acf.addFilter('acfe/fields/button/data/name=importer_les_venues', function(data, $el){
|
||||||
|
console.log('data');
|
||||||
|
// add custom key
|
||||||
|
data.custom_key = 'value';
|
||||||
|
|
||||||
|
// return
|
||||||
|
return data;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Button: Before Ajax Request
|
||||||
|
*
|
||||||
|
* @jQuery $el jQuery field element
|
||||||
|
* @Json data Ajax data
|
||||||
|
*/
|
||||||
|
|
||||||
|
// action('acfe/fields/button/before', $el, data);
|
||||||
|
// action('acfe/fields/button/before/name=importer', $el, data);
|
||||||
|
// action('acfe/fields/button/before/key=field_6213688a5f49e', $el, data);
|
||||||
|
acf.addAction('acfe/fields/button/before/name=importer_les_venues', function($el, data){
|
||||||
|
// log arguments
|
||||||
|
console.log($el);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Button: Ajax Success
|
||||||
|
*
|
||||||
|
* @jQuery $el jQuery field element
|
||||||
|
* @Json data Ajax data
|
||||||
|
*/
|
||||||
|
|
||||||
|
// action('acfe/fields/button/success', response, $el, data);
|
||||||
|
// action('acfe/fields/button/success/name=importer', response, $el, data);
|
||||||
|
// action('acfe/fields/button/success/key=field_6213688a5f49e', response, $el, data);
|
||||||
|
acf.addAction('acfe/fields/button/success/name=importer_les_venues', function(response, $el, data){
|
||||||
|
console.log('success');
|
||||||
|
// json success was sent
|
||||||
|
if(response.success){
|
||||||
|
|
||||||
|
// log arguments
|
||||||
|
console.log(response.data);
|
||||||
|
console.log($el);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Button: Ajax Complete
|
||||||
|
*
|
||||||
|
* @jQuery $el jQuery field element
|
||||||
|
* @Json data Ajax data
|
||||||
|
*/
|
||||||
|
|
||||||
|
// action('acfe/fields/button/complete', response, $el, data);
|
||||||
|
// action('acfe/fields/button/complete/name=importer', response, $el, data);
|
||||||
|
// action('acfe/fields/button/complete/key=field_6213688a5f49e', response, $el, data);
|
||||||
|
|
||||||
|
acf.addAction('acfe/fields/button/complete/name=importer_les_venues', function(response, $el, data){
|
||||||
|
console.log('complete');
|
||||||
|
// parse json response
|
||||||
|
response = JSON.parse(response);
|
||||||
|
|
||||||
|
// log arguments
|
||||||
|
console.log(response);
|
||||||
|
console.log($el);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
27
eo-import-venues/readme.txt
Normal file
27
eo-import-venues/readme.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
=== Your Site's Functionality Plugin ===
|
||||||
|
Requires at least: 3.1
|
||||||
|
Tested up to: 3.1
|
||||||
|
Stable tag: 0.1
|
||||||
|
|
||||||
|
All of the important functionality of your site belongs in this. Describe what it does!
|
||||||
|
|
||||||
|
== Description ==
|
||||||
|
|
||||||
|
Plugin description, any special instructions. If nothing else, include the URL of the site that this plugin belongs to.
|
||||||
|
|
||||||
|
== Important Notes ==
|
||||||
|
|
||||||
|
= Something to remember =
|
||||||
|
|
||||||
|
Don't forget about this important thing your plugin does!
|
||||||
|
|
||||||
|
= Something else to remember =
|
||||||
|
|
||||||
|
Don't forget this other part too!
|
||||||
|
|
||||||
|
== Changelog ==
|
||||||
|
= 0.1 =
|
||||||
|
* Note what is involved in the new version. Any changes. Include a date like 05/2011.
|
||||||
|
|
||||||
|
= 0.0 =
|
||||||
|
* Don't start your plugin at 0.0. That's just dumb.
|
28
hello-elementor-child/functions.php
Normal file
28
hello-elementor-child/functions.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php /*
|
||||||
|
|
||||||
|
This file is part of a child theme called hello elementor child.
|
||||||
|
Functions in this file will be loaded before the parent theme's functions.
|
||||||
|
For more information, please read
|
||||||
|
https://developer.wordpress.org/themes/advanced-topics/child-themes/
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// this code loads the parent's stylesheet (leave it in place unless you know what you're doing)
|
||||||
|
|
||||||
|
function your_theme_enqueue_styles() {
|
||||||
|
|
||||||
|
$parent_style = 'parent-style';
|
||||||
|
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), wp_get_theme()->get('Version') );
|
||||||
|
}
|
||||||
|
add_action('wp_enqueue_scripts', 'your_theme_enqueue_styles');
|
||||||
|
|
||||||
|
/* Add your own functions below this line.
|
||||||
|
======================================== */
|
||||||
|
|
||||||
|
|
||||||
|
/* disable toolset fields from drupal. */
|
||||||
|
add_action( 'admin_enqueue_scripts', 'load_custom_script' );
|
||||||
|
function load_custom_script() {
|
||||||
|
wp_enqueue_script('custom_admin_js_script', get_stylesheet_directory_uri() . '/js/custom-admin-script.js', array('jquery'));
|
||||||
|
}
|
8
hello-elementor-child/js/custom-admin-script.js
Normal file
8
hello-elementor-child/js/custom-admin-script.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
jQuery(document).ready(function(){
|
||||||
|
jQuery('#wpcf-group-ddblock_news_item-uniquement-pour-la-consutlation input').prop("disabled",true);
|
||||||
|
jQuery('#wpcf-group-ddblock_news_item-uniquement-pour-la-consutlation button').css("display","none");
|
||||||
|
jQuery('#wpcf-group-ddblock_news_item-uniquement-pour-la-consutlation .button').css("display","none");
|
||||||
|
jQuery('#wpcf-group-ddblock_news_item-uniquement-pour-la-consutlation select').css("display","none");
|
||||||
|
|
||||||
|
|
||||||
|
});
|
BIN
hello-elementor-child/screenshot.png
Normal file
BIN
hello-elementor-child/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 308 KiB |
14
hello-elementor-child/style.css
Normal file
14
hello-elementor-child/style.css
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
Theme Name: hello elementor child
|
||||||
|
Theme URI:
|
||||||
|
Description:
|
||||||
|
Author: adm_antipode
|
||||||
|
Author URI:
|
||||||
|
Template: hello-elementor
|
||||||
|
Version: 1.0
|
||||||
|
License: GNU General Public License v2 or later
|
||||||
|
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
||||||
|
/* == Add your own styles below this line ==
|
||||||
|
--------------------------------------------*/
|
||||||
|
|
40
import-csv2cpt/css/style.css
Normal file
40
import-csv2cpt/css/style.css
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*Colours
|
||||||
|
|
||||||
|
#94bbd7
|
||||||
|
#fcd99c
|
||||||
|
#f9b53d
|
||||||
|
#a37429
|
||||||
|
#005ea0
|
||||||
|
#ee201c
|
||||||
|
#45a3a3
|
||||||
|
#98141B
|
||||||
|
|
||||||
|
|
||||||
|
Textes
|
||||||
|
--e-global-color-primary: #000000;
|
||||||
|
--e-global-color-secondary: #54595F;
|
||||||
|
--e-global-color-text: #7A7A7A;
|
||||||
|
--e-global-color-accent: #981914;
|
||||||
|
#566d7d
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* MEDIA START */
|
||||||
|
@media all and (max-width: 1400px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 1200px) {
|
||||||
|
}
|
||||||
|
@media all and (max-width: 992px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 768px) {
|
||||||
|
}
|
||||||
|
@media all and (max-width: 600px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 480px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 360px) {
|
||||||
|
}
|
229
import-csv2cpt/import-csv2cpt.php
Normal file
229
import-csv2cpt/import-csv2cpt.php
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: Import CSV2CPT
|
||||||
|
Description: This a quick and dirty way to import data into CPTs.
|
||||||
|
It requires setting up the an options page with ACF and recuperating the values from the inputs
|
||||||
|
see : https://gist.github.com/stephenharris/00a6a601b274b38a59cc82c146a95688
|
||||||
|
Add options page with ACF with file field and button.
|
||||||
|
Version: 0.1
|
||||||
|
License: GPL
|
||||||
|
Author: Richard Turner
|
||||||
|
Author URI: yoururl
|
||||||
|
Requires : ACF Pro, ACF Extended
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('FILE_FIELD','field_' . uniqid());
|
||||||
|
|
||||||
|
function import_csv2cpt_enqueue_styles(){
|
||||||
|
$template_url = get_template_directory_uri();
|
||||||
|
$plugin_url = plugin_dir_url( __FILE__ );
|
||||||
|
wp_register_style( 'import_csv2cpt-style-css', $plugin_url.'css/style.css', false, NULL, 'all');
|
||||||
|
wp_enqueue_style( 'import_csv2cpt-style-css' );
|
||||||
|
wp_register_script('import_csv2cpt-custom-script', $plugin_url . 'js/custom-script.js', array('jquery'), null, true);
|
||||||
|
wp_enqueue_script('import_csv2cpt-custom-script');
|
||||||
|
}
|
||||||
|
add_action( 'wp_enqueue_scripts', 'import_csv2cpt_enqueue_styles' );
|
||||||
|
|
||||||
|
// add_action('admin_menu', 'wpdocs_register_my_custom_submenu_page');
|
||||||
|
|
||||||
|
// function wpdocs_register_my_custom_submenu_page() {
|
||||||
|
|
||||||
|
// add_menu_page('My Custom Page', 'My Custom Page', 'manage_options', 'my-top-level-slug', 'wpdocs_my_custom_submenu_page_callback');
|
||||||
|
// add_submenu_page(
|
||||||
|
// 'my-top-level-slug',
|
||||||
|
// 'My Custom Submenu Page',
|
||||||
|
// 'My Custom Submenu Page',
|
||||||
|
// 'manage_options',
|
||||||
|
// 'my-custom-submenu-page',
|
||||||
|
// 'wpdocs_my_custom_submenu_page_callback' );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// function wpdocs_my_custom_submenu_page_callback() {
|
||||||
|
// echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
|
||||||
|
// echo '<h2>My Custom Submenu Page</h2>';
|
||||||
|
// echo '</div>';
|
||||||
|
// }
|
||||||
|
|
||||||
|
add_action('acf/init', 'my_acf_op_init');
|
||||||
|
function my_acf_op_init() {
|
||||||
|
|
||||||
|
// Check function exists.
|
||||||
|
if( function_exists('acf_add_options_page') ) {
|
||||||
|
|
||||||
|
// Register options page.
|
||||||
|
$option_page = acf_add_options_page(array(
|
||||||
|
'page_title' => __('Import CSV2CPT'),
|
||||||
|
'menu_title' => __('Import CSV2CPT'),
|
||||||
|
'menu_slug' => 'import-csv2cpt',
|
||||||
|
'capability' => 'edit_posts',
|
||||||
|
'icon_url' => 'dashicons-media-code',
|
||||||
|
'redirect' => false
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( function_exists('acf_add_local_field_group') ):
|
||||||
|
|
||||||
|
acf_add_local_field_group(array (
|
||||||
|
'key' => 'group_import_csv2cpt',
|
||||||
|
'title' => 'Import CSV to CPT',
|
||||||
|
'fields' => array (
|
||||||
|
array (
|
||||||
|
'key' => 'field_file_import_csv2cpt',
|
||||||
|
'label' => 'CSV File',
|
||||||
|
'name' => 'csv_file',
|
||||||
|
'type' => 'file',
|
||||||
|
'prefix' => '',
|
||||||
|
'instructions' => 'Use only comma separated files',
|
||||||
|
'required' => 0,
|
||||||
|
'conditional_logic' => 0,
|
||||||
|
'wrapper' => array (
|
||||||
|
'width' => '',
|
||||||
|
'class' => '',
|
||||||
|
'id' => '',
|
||||||
|
),
|
||||||
|
'default_value' => '',
|
||||||
|
'placeholder' => '',
|
||||||
|
'prepend' => '',
|
||||||
|
'append' => '',
|
||||||
|
'maxlength' => '',
|
||||||
|
'readonly' => 0,
|
||||||
|
'disabled' => 0,
|
||||||
|
),
|
||||||
|
array (
|
||||||
|
'key' => 'field_button_import_csv2cpt',
|
||||||
|
'label' => 'Importer csv data',
|
||||||
|
'name' => 'importer_csv_data',
|
||||||
|
'type' => 'acfe_button',
|
||||||
|
'prefix' => '',
|
||||||
|
'instructions' => '',
|
||||||
|
'required' => 0,
|
||||||
|
'conditional_logic' => 0,
|
||||||
|
'wrapper' => array (
|
||||||
|
'width' => '',
|
||||||
|
'class' => '',
|
||||||
|
'id' => '',
|
||||||
|
),
|
||||||
|
'default_value' => '',
|
||||||
|
'readonly' => 0,
|
||||||
|
'disabled' => 0,
|
||||||
|
'button_value' => 'Envoyer',
|
||||||
|
'button_type' => 'button',
|
||||||
|
'button_class' => 'button button-secondary',
|
||||||
|
'button_id' => '',
|
||||||
|
'button_before' => '',
|
||||||
|
'button_after' => '',
|
||||||
|
'button_ajax' => 1,
|
||||||
|
'_name' => 'importer_csv_data',
|
||||||
|
'_valid' => 1
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'location' => array (
|
||||||
|
array (
|
||||||
|
array (
|
||||||
|
'param' => 'options_page',
|
||||||
|
'operator' => '==',
|
||||||
|
'value' => 'import-csv2cpt',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'menu_order' => 10,
|
||||||
|
'position' => 'normal',
|
||||||
|
'style' => 'default',
|
||||||
|
'label_placement' => 'top',
|
||||||
|
'instruction_placement' => 'label',
|
||||||
|
'hide_on_screen' => '',
|
||||||
|
));
|
||||||
|
|
||||||
|
endif;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add_action('acfe/fields/button/key=field_button_import_csv2cpt', 'import_csv2cpt_button_ajax', 10, 2);
|
||||||
|
function import_csv2cpt_button_ajax($field, $post_id){
|
||||||
|
|
||||||
|
/*
|
||||||
|
[0] => 22
|
||||||
|
[1] => 3
|
||||||
|
[2] => 570
|
||||||
|
[3] => Anne
|
||||||
|
[4] => Belgique
|
||||||
|
[5] => Bravo pour votre prestation dans l'église de Lessines !
|
||||||
|
Les frissons étaient au rendez-vous !
|
||||||
|
[6] => 10/09/2012
|
||||||
|
[7] => 1
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$file_ID = $_POST['acf']['field_file_import_csv2cpt'];
|
||||||
|
|
||||||
|
$file = get_attached_file($file_ID);
|
||||||
|
|
||||||
|
if($file == ""){
|
||||||
|
wp_send_json_success(__LINE__." Error File is Empty file_ID:".$file_ID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $csvFile = file($file);
|
||||||
|
$csvFile = fopen($file, 'r');
|
||||||
|
$i = 0;
|
||||||
|
$count_adjusted = 0;
|
||||||
|
$i= 0;
|
||||||
|
while (($row = fgetcsv($csvFile)) !== false) {
|
||||||
|
if($i==0){
|
||||||
|
$i++;
|
||||||
|
// continue;
|
||||||
|
}
|
||||||
|
// $tmp = print_r($row,1);
|
||||||
|
// wp_send_json_success(__LINE__." End of Function:".$tmp."\n");
|
||||||
|
// return;
|
||||||
|
if(empty($row)){
|
||||||
|
wp_send_json_success(__LINE__." Error! File is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$csv_data['post_title'] = ucwords($row[3])." - ".ucwords($row[4]);
|
||||||
|
$csv_data['creation_id'] = $row[2];
|
||||||
|
$csv_data['nom'] = ucwords($row[3]);
|
||||||
|
$csv_data['pays'] = ucwords($row[4]);
|
||||||
|
$csv_data['citation'] = $row[5];
|
||||||
|
$csv_data['date'] = $row[6];
|
||||||
|
$csv_data['valide'] = $row[7];
|
||||||
|
|
||||||
|
$csv_data['post_title'] .= " - ".date( 'd.m.Y', strtotime($csv_data['date']));
|
||||||
|
|
||||||
|
// Insert the post into the database
|
||||||
|
$my_post = array(
|
||||||
|
'post_title' => wp_strip_all_tags( $csv_data['post_title'] ),
|
||||||
|
'post_content' => $csv_data['citation'],
|
||||||
|
'post_type' => 'item-livre-dor',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_author' => get_current_user_id(),
|
||||||
|
'post_date' => date( 'Y-m-d H:i:s', strtotime($csv_data['date']) ),
|
||||||
|
'post_date_gmt' => date( 'Y-m-d H:i:s', strtotime($csv_data['date']) ),
|
||||||
|
);
|
||||||
|
// Insert the post into the database
|
||||||
|
$post_id = wp_insert_post( $my_post );
|
||||||
|
$tmp .= __LINE__." Post ID:".$post_id;
|
||||||
|
|
||||||
|
update_field( 'creation', $csv_data['creation_id'], $post_id );
|
||||||
|
update_field( 'citation', $csv_data['citation'], $post_id );
|
||||||
|
update_field( 'nom', $csv_data['nom'], $post_id );
|
||||||
|
update_field( 'pays', $csv_data['pays'], $post_id );
|
||||||
|
update_field( 'date', $csv_data['date'], $post_id );
|
||||||
|
update_field( 'valide', $csv_data['valide'], $post_id );
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_send_json_success(__LINE__." End of Function:".$tmp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action('acf/input/admin_enqueue_scripts', 'import_cpt_admin_enqueue_scripts');
|
||||||
|
function import_cpt_admin_enqueue_scripts() {
|
||||||
|
$plugin_url = plugin_dir_url( __FILE__ );
|
||||||
|
wp_enqueue_script( 'import-csv2cpt-acf-input-js', $plugin_url . 'js/import-csv2cpt-acf-input.js', false, '1.0.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
2
import-csv2cpt/js/custom-script.js
Normal file
2
import-csv2cpt/js/custom-script.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
jQuery(document).ready(function($) {
|
||||||
|
});
|
89
import-csv2cpt/js/import-csv2cpt-acf-input.js
Normal file
89
import-csv2cpt/js/import-csv2cpt-acf-input.js
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
jQuery(document).ready(function($) {
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Button: Ajax Data
|
||||||
|
*
|
||||||
|
* @Json data Ajax data
|
||||||
|
* @jQuery $el jQuery field element
|
||||||
|
*/
|
||||||
|
|
||||||
|
// filter('acfe/fields/button/data', data, $el);
|
||||||
|
// filter('acfe/fields/button/data/name=importer', data, $el);
|
||||||
|
// filter('acfe/fields/button/data/key=field_6213688a5f49e', data, $el);
|
||||||
|
// acf.addFilter('acfe/fields/button/data/name=importer_csv_data', function(data, $el){
|
||||||
|
acf.addFilter('acfe/fields/button/data/key=field_button_import_csv2cpt', function(data, $el){
|
||||||
|
console.log('data function');
|
||||||
|
console.log(data);
|
||||||
|
data.custom_key = 'value';
|
||||||
|
return data;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Button: Before Ajax Request
|
||||||
|
*
|
||||||
|
* @jQuery $el jQuery field element
|
||||||
|
* @Json data Ajax data
|
||||||
|
*/
|
||||||
|
|
||||||
|
// action('acfe/fields/button/before', $el, data);
|
||||||
|
// action('acfe/fields/button/before/name=importer', $el, data);
|
||||||
|
// action('acfe/fields/button/before/key=field_6213688a5f49e', $el, data);
|
||||||
|
// acf.addAction('acfe/fields/button/before/name=importer_csv_data', function($el, data){
|
||||||
|
acf.addAction('acfe/fields/button/before/key=field_button_import_csv2cpt', function( $el, data){
|
||||||
|
// log arguments
|
||||||
|
console.log('before function');
|
||||||
|
console.log($el);
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Button: Ajax Success
|
||||||
|
*
|
||||||
|
* @jQuery $el jQuery field element
|
||||||
|
* @Json data Ajax data
|
||||||
|
*/
|
||||||
|
|
||||||
|
// action('acfe/fields/button/success', response, $el, data);
|
||||||
|
// action('acfe/fields/button/success/name=importer', response, $el, data);
|
||||||
|
// action('acfe/fields/button/success/key=field_6213688a5f49e', response, $el, data);
|
||||||
|
// acf.addAction('acfe/fields/button/success/name=importer_csv_data', function(response, $el, data){
|
||||||
|
acf.addAction('acfe/fields/button/success/key=field_button_import_csv2cpt', function(response, $el, data){
|
||||||
|
console.log('success');
|
||||||
|
// json success was sent
|
||||||
|
if(response.success){
|
||||||
|
|
||||||
|
// log arguments
|
||||||
|
console.log($el);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Button: Ajax Complete
|
||||||
|
*
|
||||||
|
* @jQuery $el jQuery field element
|
||||||
|
* @Json data Ajax data
|
||||||
|
*/
|
||||||
|
|
||||||
|
// action('acfe/fields/button/complete', response, $el, data);
|
||||||
|
// action('acfe/fields/button/complete/name=importer', response, $el, data);
|
||||||
|
// action('acfe/fields/button/complete/key=field_6213688a5f49e', response, $el, data);
|
||||||
|
|
||||||
|
// acf.addAction('acfe/fields/button/complete/name=importer_csv_data', function(response, $el, data){
|
||||||
|
acf.addAction('acfe/fields/button/complete/key=field_button_import_csv2cpt', function(response, $el, data){
|
||||||
|
console.log('complete');
|
||||||
|
// parse json response
|
||||||
|
|
||||||
|
response = JSON.parse(response);
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
console.log($el);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
27
import-csv2cpt/readme.txt
Normal file
27
import-csv2cpt/readme.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
=== Your Site's Functionality Plugin ===
|
||||||
|
Requires at least: 3.1
|
||||||
|
Tested up to: 3.1
|
||||||
|
Stable tag: 0.1
|
||||||
|
|
||||||
|
All of the important functionality of your site belongs in this. Describe what it does!
|
||||||
|
|
||||||
|
== Description ==
|
||||||
|
|
||||||
|
Plugin description, any special instructions. If nothing else, include the URL of the site that this plugin belongs to.
|
||||||
|
|
||||||
|
== Important Notes ==
|
||||||
|
|
||||||
|
= Something to remember =
|
||||||
|
|
||||||
|
Don't forget about this important thing your plugin does!
|
||||||
|
|
||||||
|
= Something else to remember =
|
||||||
|
|
||||||
|
Don't forget this other part too!
|
||||||
|
|
||||||
|
== Changelog ==
|
||||||
|
= 0.1 =
|
||||||
|
* Note what is involved in the new version. Any changes. Include a date like 05/2011.
|
||||||
|
|
||||||
|
= 0.0 =
|
||||||
|
* Don't start your plugin at 0.0. That's just dumb.
|
40
my-utility-plugin-V2/css/style.css
Normal file
40
my-utility-plugin-V2/css/style.css
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*Colours
|
||||||
|
|
||||||
|
#94bbd7
|
||||||
|
#fcd99c
|
||||||
|
#f9b53d
|
||||||
|
#a37429
|
||||||
|
#005ea0
|
||||||
|
#ee201c
|
||||||
|
#45a3a3
|
||||||
|
#98141B
|
||||||
|
|
||||||
|
|
||||||
|
Textes
|
||||||
|
--e-global-color-primary: #000000;
|
||||||
|
--e-global-color-secondary: #54595F;
|
||||||
|
--e-global-color-text: #7A7A7A;
|
||||||
|
--e-global-color-accent: #981914;
|
||||||
|
#566d7d
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* MEDIA START */
|
||||||
|
@media all and (max-width: 1400px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 1200px) {
|
||||||
|
}
|
||||||
|
@media all and (max-width: 992px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 768px) {
|
||||||
|
}
|
||||||
|
@media all and (max-width: 600px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 480px) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 360px) {
|
||||||
|
}
|
2
my-utility-plugin-V2/js/custom-script.js
Normal file
2
my-utility-plugin-V2/js/custom-script.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
jQuery(document).ready(function($) {
|
||||||
|
});
|
24
my-utility-plugin-V2/my-utility-plugin-V2.php
Normal file
24
my-utility-plugin-V2/my-utility-plugin-V2.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: MUP Plugin
|
||||||
|
Description: All of the important functionality of your site belongs in this.
|
||||||
|
Version: 0.1
|
||||||
|
License: GPL
|
||||||
|
Author: Your Name
|
||||||
|
Author URI: yoururl
|
||||||
|
*/
|
||||||
|
|
||||||
|
function pgm_enqueue_styles(){
|
||||||
|
$template_url = get_template_directory_uri();
|
||||||
|
$plugin_url = plugin_dir_url( __FILE__ );
|
||||||
|
wp_register_style( 'pgm-style-css', $plugin_url.'css/style.css', false, NULL, 'all');
|
||||||
|
wp_enqueue_style( 'pgm-style-css' );
|
||||||
|
wp_register_script('pgm-custom-script', $plugin_url . 'js/custom-script.js', array('jquery'), null, true);
|
||||||
|
wp_enqueue_script('pgm-custom-script');
|
||||||
|
|
||||||
|
}
|
||||||
|
add_action( 'wp_enqueue_scripts', 'pgm_enqueue_styles' );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
27
my-utility-plugin-V2/readme.txt
Normal file
27
my-utility-plugin-V2/readme.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
=== Your Site's Functionality Plugin ===
|
||||||
|
Requires at least: 3.1
|
||||||
|
Tested up to: 3.1
|
||||||
|
Stable tag: 0.1
|
||||||
|
|
||||||
|
All of the important functionality of your site belongs in this. Describe what it does!
|
||||||
|
|
||||||
|
== Description ==
|
||||||
|
|
||||||
|
Plugin description, any special instructions. If nothing else, include the URL of the site that this plugin belongs to.
|
||||||
|
|
||||||
|
== Important Notes ==
|
||||||
|
|
||||||
|
= Something to remember =
|
||||||
|
|
||||||
|
Don't forget about this important thing your plugin does!
|
||||||
|
|
||||||
|
= Something else to remember =
|
||||||
|
|
||||||
|
Don't forget this other part too!
|
||||||
|
|
||||||
|
== Changelog ==
|
||||||
|
= 0.1 =
|
||||||
|
* Note what is involved in the new version. Any changes. Include a date like 05/2011.
|
||||||
|
|
||||||
|
= 0.0 =
|
||||||
|
* Don't start your plugin at 0.0. That's just dumb.
|
147
update_wp_sites.sh
Normal file
147
update_wp_sites.sh
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
WEB_ROOT="/var/www"
|
||||||
|
# Check if the web root directory exists
|
||||||
|
if [ ! -d "$WEB_ROOT" ]; then
|
||||||
|
echo "Web root directory not found: $WEB_ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
menu1="select the operation ************\r\n"
|
||||||
|
menu1="${menu1} 1) list admin users\r\n"
|
||||||
|
menu1="${menu1} 2) list themes\r\n"
|
||||||
|
menu1="${menu1} 3) update themes\r\n"
|
||||||
|
menu1="${menu1} 4) list plugins\r\n"
|
||||||
|
menu1="${menu1} 5) update plugins\r\n"
|
||||||
|
menu1="${menu1} E) Exit\r\n"
|
||||||
|
|
||||||
|
done=0
|
||||||
|
while [ $done -eq 0 ]
|
||||||
|
do
|
||||||
|
echo -e ${menu1}
|
||||||
|
read n
|
||||||
|
done=1
|
||||||
|
case $n in
|
||||||
|
1) selected_action="user list --role=administrator"
|
||||||
|
echo "You chose to list admin users";;
|
||||||
|
2) selected_action="theme list"
|
||||||
|
echo "You chose to list themes";;
|
||||||
|
3) selected_action="theme update"
|
||||||
|
echo "You chose to update themes";;
|
||||||
|
4) selected_action="plugin list"
|
||||||
|
echo "You chose to list plugins";;
|
||||||
|
5) selected_action="plugin update"
|
||||||
|
echo "You chose to update plugins";;
|
||||||
|
E) exit;;
|
||||||
|
e) exit;;
|
||||||
|
*) echo "invalid option"
|
||||||
|
done=0;;
|
||||||
|
esac
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
# Loop through each directory in the web root
|
||||||
|
number=1
|
||||||
|
|
||||||
|
cd $WEB_ROOT
|
||||||
|
menu2="select the site(s) ************\r\n"
|
||||||
|
|
||||||
|
folders="$(find . -maxdepth 1 -type l)"
|
||||||
|
|
||||||
|
for site_dir in $folders; do
|
||||||
|
if [ -d "$site_dir"/web/wp-content ]; then
|
||||||
|
site_dir_name=$(basename "$site_dir")
|
||||||
|
site_dir_name_array+=("$site_dir_name")
|
||||||
|
menu2="${menu2} $number: $site_dir_name\r\n"
|
||||||
|
number=`expr $number + 1`
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
menu2="${menu2} A: All\r\n"
|
||||||
|
menu2="${menu2} E) Exit\r\n"
|
||||||
|
#echo "---"$number
|
||||||
|
|
||||||
|
done=0
|
||||||
|
while [ $done -eq 0 ]
|
||||||
|
do
|
||||||
|
echo -e ${menu2}
|
||||||
|
read n
|
||||||
|
done=1
|
||||||
|
|
||||||
|
case $n in
|
||||||
|
A) selected_sites="all"
|
||||||
|
echo "You chose All";;
|
||||||
|
a) selected_sites="all"
|
||||||
|
echo "You chose All";;
|
||||||
|
[0-$number])
|
||||||
|
n=`expr $n - 1`
|
||||||
|
if [ -d ${site_dir_name_array[${n}]} ]; then
|
||||||
|
selected_sites=""${site_dir_name_array[${n}]}
|
||||||
|
echo "You chose "$selected_sites
|
||||||
|
else
|
||||||
|
echo "invalid option"
|
||||||
|
done=0
|
||||||
|
fi;;
|
||||||
|
E) exit;;
|
||||||
|
e) exit;;
|
||||||
|
*) echo "invalid option"
|
||||||
|
done=0;;
|
||||||
|
esac
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $selected_sites == "all" ]; then
|
||||||
|
for site in "${site_dir_name_array[@]}"; do
|
||||||
|
|
||||||
|
link=$(readlink "$WEB_ROOT/$site")
|
||||||
|
|
||||||
|
owner=$(basename "$link")
|
||||||
|
cd $WEB_ROOT/$site/web/
|
||||||
|
sudo -u $owner wp $selected_action
|
||||||
|
cd -
|
||||||
|
done
|
||||||
|
else
|
||||||
|
link=$(readlink "$WEB_ROOT/$selected_sites")
|
||||||
|
owner=$(basename "$link")
|
||||||
|
cd $WEB_ROOT/$selected_sites/web/
|
||||||
|
sudo -u $owner wp $selected_action
|
||||||
|
cd -
|
||||||
|
fi
|
||||||
|
exit
|
||||||
|
# Loop through each directory in the web root
|
||||||
|
for client_dir in "$WEB_ROOT"/*/; do
|
||||||
|
if [ -d "$client_dir" ]; then
|
||||||
|
client_dir_name=$(basename "$client_dir")
|
||||||
|
if [[ "$client_dir_name" == client* ]]; then
|
||||||
|
|
||||||
|
for site_dir in "$client_dir"*/; do
|
||||||
|
if [ -d "$site_dir" ]; then
|
||||||
|
|
||||||
|
site_dir_name=$(basename "$site_dir")
|
||||||
|
|
||||||
|
if [[ "$site_dir_name" == web* ]]; then
|
||||||
|
|
||||||
|
if [ -d "$site_dir"web/wp-content ]; then
|
||||||
|
echo "Processing site: $site_dir_name"
|
||||||
|
echo
|
||||||
|
cd "$site_dir"web/
|
||||||
|
if [ "$1" ]; then
|
||||||
|
# sudo -u $site_dir_name wp theme list
|
||||||
|
# sudo -u $site_dir_name wp plugin list
|
||||||
|
#sudo -u $site_dir_name wp user list --role=administrator --format=csv
|
||||||
|
#sudo -u $site_dir_name wp $1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd -
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Finished processing client: $client_dir_name"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user