Skip to content

Instantly share code, notes, and snippets.

View racmanuel's full-sized avatar
💡
Making new things!

Manuel Ramirez Coronel racmanuel

💡
Making new things!
View GitHub Profile
<?php
/*
Plugin Name: Add Gift Card as Custom Product Type
Description: A simple demo plugin on how to add Gift Card as your custom product type
Author: Bhavik Kiri
Version: 1.0
*/
add_action( 'plugins_loaded', 'wcpt_register_gift_card_type' );
<?php
/**
*
* You can find the complete tutorial for this here:
* https://pluginrepublic.com/woocommerce-custom-fields
*
* Alternatively, check out the plugin
* https://pluginrepublic.com/wordpress-plugins/woocommerce-product-add-ons-ultimate/
*
@racmanuel
racmanuel / cf7_external_db2018.php
Created September 27, 2022 17:01 — forked from jc4316son/cf7_external_db2018.php
Contact Form 7 to External DB 2018
<?php
/*
Plugin Name: Contact Form 7 to External DB
Plugin URI:
Description: This plugin uses the wpcf7_before_send_mail hook to post a specific form to an external database. Upon use the details for your external database will need to be entered. Private use only.
Author:
Version: 0.2
Author URI:
*/
@racmanuel
racmanuel / functions.php
Created August 2, 2022 15:52
remplace a list field of gravity forms with select and get the results from external api
<?php
add_filter( 'gform_column_input_2_15_1', 'set_column', 10, 5 );
function set_column( $input_info, $field, $column, $value, $form_id ) {
$request = wp_remote_get( 'https://pippinsplugins.com/edd-api/products' );
if( is_wp_error( $request ) ) {
return false; // Bail early
}
$body = wp_remote_retrieve_body( $request );
<?php
add_action( 'woocommerce_before_single_product', 'bbloomer_show_video_not_image' );
function bbloomer_show_video_not_image() {
// Do this for product ID = 282 only
if ( is_single( '282' ) ) {
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
@racmanuel
racmanuel / functions.php
Created July 4, 2022 16:20
AL CERRAR SESION EN LA PAGINA REDIRIGE AL USUARIO A LA PAGINA DE INICIO.
<?php
// AL CERRAR SESION EN LA PAGINA REDIRIGE AL USUARIO A LA PAGINA DE INICIO.
function auto_redirect_after_logout()
{
wp_redirect(home_url());
exit();
}
add_action('wp_logout', 'auto_redirect_after_logout');
@racmanuel
racmanuel / functions.php
Created July 4, 2022 16:19
MUESTRA EL MENU DIFERENTE EN LAS PAGINAS DEPENDIENDO SI EL USUARIO CUENTA CON UNA SESSION ACTIVA O DESACTIVADA.
<?php
// MUESTRA EL MENU DIFERENTE EN LAS PAGINAS DEPENDIENDO SI EL USUARIO CUENTA CON UNA SESSION ACTIVA O DESACTIVADA.
function my_wp_nav_menu_args($args = '')
{
if (is_user_logged_in()) {
$args['menu'] = 'Menú Principal - Log In';
return $args;
} else {
$args['menu'] = 'Menú Principal - Log Out';
return $args;
@racmanuel
racmanuel / gist:8df1031fc9de7ed28b3cbceee1051a22
Created April 21, 2022 17:13 — forked from bueltge/gist:757903
This WordPress Plugin demonstrates how you can build your own plugin pages using the WordPress provided draggable metaboxes, requires WordPress 2.7 version, supports WordPress 2.8 changed boxing layout engine
<?php
/*
Plugin Name: HowTo Plugin
Plugin URI:
Description: This Plugin demonstrates how you can build your own plugin pages using the WordPress provided draggable metaboxes, requires WordPress 2.7 version, supports WordPress 2.8 changed boxing layout engine
Author: Heiko, Frank
Author URI: http://bueltge.de
Version: 0.1
License:
@racmanuel
racmanuel / disable-front-end.php
Created April 13, 2022 22:17
Disable the frontend interface of the website, leave only CMS and REST API
<?php
/*
Plugin Name: Disable Frontend
Description: Disable the frontend interface of the website, leave only CMS and REST API
Version: 1.0
*/
add_action('init', 'redirect_to_backend');
function redirect_to_backend() {
// Enable WP_DEBUG mode
define('WP_DEBUG', true);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Disable display of errors and warnings
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);