Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gregoirenoyelle/a1710646aede31737773 to your computer and use it in GitHub Desktop.
Save gregoirenoyelle/a1710646aede31737773 to your computer and use it in GitHub Desktop.
WordPress Extension de Thème
<?php
/*
Plugin Name: Options pour WooCommerce
Plugin URI: https://wwww.gregoirenoyelle.com
Description: Changer des réglage de WooCommerce depuis une extension.
Version: 2.0
Author: Grégoire Noyelle
Author URI: http://wwww.gregoirenoyelle.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Domain Path: /languages
Text Domain: wp-plugin-name
*/
//* If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
die;
}
/**************************
* LIENS FICHIER PHP
**************************/
//* Appel autres fichiers PHP
// Fichier de functions pour WordPress
include_once plugin_dir_path( __FILE__ ) . 'lib/func.wordpress.php';
// Fichier de functions pour Woocommerce
include_once plugin_dir_path( __FILE__ ) . 'lib/func.woocommerce.php';
// Fichier de functions pour Genesis
// include_once plugin_dir_path( __FILE__ ) . 'lib/func.genesis.php';
// Fichier de functions pour intégrer des CSS et JS
include_once plugin_dir_path( __FILE__ ) . 'lib/func.enqueue.php';
<?php
/*
Plugin Name: gnoyelle : Options du thème par Grégoire
Plugin URI: http://wwww.gregoirenoyelle.com
Description: Toutes les options suplémentaires pour le thème
Version: 1.0
Author: Grégoire Noyelle
Author URI: http://wwww.gregoirenoyelle.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Domain Path: /languages
Text Domain: wp-plugin-name
*/
//* If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
die;
}
/**************************
* LIENS FICHIER PHP
**************************/
//* Appel autres fichiers PHP
// Fichier de functions pour WordPress
include_once(plugin_dir_path( __FILE__ ) . 'lib/func.wordpress.php');
// Fichier de functions pour Genesis
include_once(plugin_dir_path( __FILE__ ) . 'lib/func.genesis.php');
// Fichier de functions pour intégrer des CSS et JS
include_once(plugin_dir_path( __FILE__ ) . 'lib/func.enqueue.php');
<?php
//* Générateur en ligne pour les script et les css
// https://generatewp.com/register_script/
/**************************
* ENQUEUE POUR LE FRONT
**************************/
//* enqueue style front
add_action('wp_enqueue_scripts','gnwooc2_styles_front', 999);
function gnwooc2_styles_front() {
wp_register_style('gn-woocom-css', plugin_dir_url(__DIR__ ) . 'css/gn-woocom.css', array(), '1.0', 'all' );
// Enqueue CSS si WooCommerce est actif
if ( class_exists( 'WooCommerce' ) ) {
wp_enqueue_style('gn-woocom-css');
}
}
//* enqueue script front
// add_action('wp_enqueue_scripts','gnwooc2_scripts_front');
function gnwooc2_scripts_front() {
wp_register_script('scripts-projet-front', plugin_dir_url(__DIR__ ) . 'js/scripts-projet-front.js', array(),'1.0',true);
wp_enqueue_script('scripts-projet-front');
}
/**************************
* ENQUEUE POUR LE BACK
**************************/
//* enqueue style back
// Non actif avec le commentaire
// add_action('admin_enqueue_scripts','gnwooc2_styles_back', 99);
function gnwooc2_styles_back() {
wp_register_style('styles-projet-back', plugin_dir_url(__DIR__ ) . 'css/styles-projet-back.css', array(), '1.0', 'all' );
wp_enqueue_style('styles-projet-back');
}
//* enqueue script back
// Non actif avec le commentaire
// add_action('admin_enqueue_scripts','gnwooc2_scripts_back');
function gnwooc2_scripts_back() {
wp_register_script('scripts-projet-back', plugin_dir_url(__DIR__ ) . 'js/scripts-projet-back.js', array(), '1.0',true);
wp_enqueue_script('scripts-projet-back');
}
<?php
//* Générateur en ligne pour les script et les css
// https://generatewp.com/register_script/
/**************************
* ENQUEUE POUR LE FRONT
**************************/
//* enqueue style front
add_action('wp_enqueue_scripts','gn_styles_front', 99);
function gn_styles_front() {
wp_register_style('styles-projet-front', plugin_dir_url(__DIR__ ) . 'css/styles-projet-front.css', array(), '1.0', 'all' );
wp_enqueue_style('styles-projet-front');
}
//* enqueue script front
add_action('wp_enqueue_scripts','gn_scripts_front');
function gn_scripts_front() {
wp_register_script('scripts-projet-front', plugin_dir_url(__DIR__ ) . 'js/scripts-projet-front.js', array(), '1.0',true);
wp_enqueue_script('scripts-projet-front');
}
/**************************
* ENQUEUE POUR LE BACK
**************************/
//* enqueue style back
add_action('admin_enqueue_scripts','gn_styles_back', 99);
function gn_styles_back() {
wp_register_style('styles-projet-back', plugin_dir_url(__DIR__ ) . 'css/styles-projet-back.css', array(), '1.0', 'all' );
wp_enqueue_style('styles-projet-back');
}
//* enqueue script back
add_action('admin_enqueue_scripts','gn_scripts_back');
function gn_scripts_back() {
wp_register_script('scripts-projet-back', plugin_dir_url(__DIR__ ) . 'js/scripts-projet-back.js', array(),'1.0',true);
wp_enqueue_script('scripts-projet-back');
}
<?php
/*
Plugin Name: WP Plugin Name
Plugin URI: https://www.gregoirenoyelle.com/wp-plugin-name
Description: A simple WordPress plugin
Version: 1.0
Author: Grégoire Noyelle
Author URI: https://www.gregoirenoyelle.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Domain Path: /languages
Text Domain: wp-plugin-name
*/
/*
Copyright 2016 Grégoire Noyelle (email : [email protected])
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
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment