Skip to content

Instantly share code, notes, and snippets.

View ckaklamanos's full-sized avatar

Haris Kaklamanos ckaklamanos

View GitHub Profile
@ckaklamanos
ckaklamanos / gist:c7404a64958afea013b1fd88520b97bc
Last active June 2, 2020 12:43
CS-Cart MySQL find duplicate product codes
SELECT `product_code`, COUNT(*) c FROM [prefix]_products GROUP BY `product_code` HAVING c > 1
#Show product names
SELECT a.product_code,a.status,b.product
FROM xxx_products AS a
LEFT JOIN xxx_product_descriptions AS b
ON a.product_id= b.product_id
WHERE a.product_code
IN (SELECT product_code FROM xxx_products GROUP BY product_code HAVING COUNT(product_code) > 1)
@ckaklamanos
ckaklamanos / remove_wordpress_dashboard_widgets.php
Created January 25, 2020 12:55
Remove WordPress Dashboard Widgets (for non-Administrators)
<?php
function fn_remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
@ckaklamanos
ckaklamanos / hide_notify_register_from_new_user_form.php
Created January 25, 2020 13:40
Hide "Send the new user an email about their account."
add_action( 'user_new_form', 'fn_hide_notify_register_from_new_user_form' );
function fn_hide_notify_register_from_new_user_form() {
echo '<script>jQuery(document).ready(function($) {
$(".user-new-php #send_user_notification").closest("tr").hide();
} ); </script>';
}
@ckaklamanos
ckaklamanos / uncheck_notify_register_on_new_user_form.php
Created January 25, 2020 13:41
Uncheck "Send the new user an email about their account." by default
add_action( 'user_new_form', 'fn_uncheck_notify_register_on_new_user_form' );
function fn_uncheck_notify_register_on_new_user_form() {
echo '<script>jQuery(document).ready(function($) {
$("#send_user_notification").removeAttr("checked");
} ); </script>';
}
@ckaklamanos
ckaklamanos / wordpress_hide_personal_options_section_from_user_edit_screen.php
Last active January 25, 2020 14:04
WordPress: Hide "Personal Options" section from User Edit screen (for non-Administrators)
<?php
function fn_hide_personal_options_section_from_user_edit_screen(){
echo '<script>jQuery(document).ready(function($) {
$(".user-edit-php .user-admin-color-wrap").closest(".form-table").hide();
$(".user-edit-php .user-admin-color-wrap").closest(".form-table").prev("h2").hide();
} ); </script>';
}
if (!current_user_can('manage_options')) {
@ckaklamanos
ckaklamanos / wordpress_yoast_seo_remove_social_fields_and_hide_settings.php
Created January 27, 2020 09:09
Wordpress Yoast SEO - Remove user Social fields and Hide Yoast Profile settings (for non-Administrators)
<?php
if (!current_user_can('manage_options')) {
add_filter('user_contactmethods', 'fn_yoast_seo_remove_user_social_fields',99);
}
function fn_yoast_seo_remove_user_social_fields ( $contactmethods ) {
unset( $contactmethods['facebook'] );
unset( $contactmethods['instagram'] );
unset( $contactmethods['linkedin'] );
@ckaklamanos
ckaklamanos / woocommerce_remove_product_data_tabs.php
Created February 6, 2020 12:19
WooCommerce Remove Product Data Tabs (for non-Administrators)
<?php
function fn_remove_product_data_tabs($tabs) {
//unset($tabs['general']);
//unset($tabs['inventory']);
//unset($tabs['linked_product']);
//unset($tabs['shipping']);
//unset($tabs['attribute']);
//unset($tabs['variations']);
@ckaklamanos
ckaklamanos / wp_astra_remove_metabox_per_post_type.php
Created February 6, 2020 12:30
WP Astra Theme Remove Meta Box per Post Type (for non-Administrators)
<?php
function fn_remove_astra_metabox_per_post_type() {
$post_types = array(
//'page',
//'product',
//'post',
);
@ckaklamanos
ckaklamanos / wordpress_add_inline_script_to_footer_for_smooth_scroll_to_anchor_links.php
Created February 20, 2020 09:19
WordPress Add inline script for Javascript smooth scroll to anchor links
@ckaklamanos
ckaklamanos / apache_htaccess_block_urls_by_regex.txt
Created March 7, 2020 07:59
Apache .htaccess - Block URLs by regex
RewriteEngine On
RewriteRule ^something(.*)$|^somethingelse(.*)$ - [F]