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
@J-H-Mojumder
J-H-Mojumder / functions.php
Created January 28, 2022 10:59
Use [dokan_vendor_dashbord] shortcode to show the "Go to Vendor Dashboard" button on any page you want when a vendor is logged in.
<?php
add_shortcode( 'dokan_vendor_dashbord', 'dokan_show_vendor_dashboard_url' );
function dokan_show_vendor_dashboard_url() {
if ( ! dokan_is_user_seller( get_current_user_id() ) ) {
return;
}
printf(
'<p><a href="%s" class="dokan-btn dokan-btn-theme vendor-dashboard" >%s</a></p>',
@jayeshhpatel
jayeshhpatel / DataTables Server Side Processing in WordPress (functions.php)
Last active December 23, 2023 06:05
DataTables Server Side Processing in WordPress
Add the following piece of code to your functions.php file.
add_shortcode('getMembership-lists', 'ajax_membership_table_shortcode');
// WITH AJAX LOAD TABLE
function membership_datatables_scripts() {
wp_register_style('datatables_style', '//cdn.datatables.net/1.11.1/css/jquery.dataTables.min.css');
wp_enqueue_style('datatables_style');
@jmarreros
jmarreros / mostrar-datos-api-externa-WordPress.php
Last active November 24, 2023 00:20
Muestra datos de una API externa de ejemplo en una página específica de WordPress
<?php //No copiar esta línea
// Filtro para agregar contenido a una página de WordPress
add_filter('the_content', 'dcms_add_custom_content');
// Agregamos contenido sólo a la página con el título "Contenido Vinos"
function dcms_add_custom_content($content){
if ( ! is_page('contenido-vinos') ) return $content;
<?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 );
@nayemDevs
nayemDevs / functions.php
Created February 2, 2021 04:00
Show only free shipping and hide other shipping methods
/**
* Hide shipping rates when free shipping is available.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function dokan_vendor_shipping_hide_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
<? // no copiar esta línea
add_filter( 'the_content', 'dcms_list_data' );
function dcms_list_data( $content ) {
$database_name = 'employees'; // nombre de la base de datos
$database_user = 'root';
$database_pass = 'root';
$database_server = 'localhost';
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Add custom fee to cart automatically
*
*/
function woo_add_cart_fee() {
@nayemDevs
nayemDevs / functions.php
Last active March 12, 2024 15:13
Price and Image field required
/**
* Validation add for product cover image
*
* @param array $errors
* @return array $errors
*/
function dokan_can_add_product_validation_customized( $errors ) {
$postdata = wp_unslash( $_POST );
$featured_image = absint( sanitize_text_field( $postdata['feat_image_id'] ) );
$_regular_price = absint( sanitize_text_field( $postdata['_regular_price'] ) );
@nayemDevs
nayemDevs / functions.php
Last active November 29, 2023 23:18
Saving extra field value and showing on user profile = vendor registration form
function dokan_custom_seller_registration_required_fields( $required_fields ) {
$required_fields['gst_id'] = __( 'Please enter your GST number', 'dokan-custom' );
return $required_fields;
};
add_filter( 'dokan_seller_registration_required_fields', 'dokan_custom_seller_registration_required_fields' );
@maheshwaghmare
maheshwaghmare / custom-sortable-columns.php
Created May 22, 2020 09:38
WordPress - Add custom sortable columns for custom post type.
<?php
/**
* Add custom column
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
if( ! function_exists( 'prefix_add_custom_column' ) ) :
function prefix_add_custom_column( $columns = array() ) {