Skip to content

Instantly share code, notes, and snippets.

View rajucs's full-sized avatar
🎯
Focusing

Arman Hossain rajucs

🎯
Focusing
View GitHub Profile
/**
* Hardcodes shop item in navigation
* @param string $items HTML with navigation items
* @param object $args navigation menu arguments
* @return string all navigation items HTML
*/
function new_nav_menu_items($items, $args) {
if($args->theme_location == 'main-menu'){
$shop_item = '<li class="spec"><a href="#" title="title">title</a></li>';
$items = $items . $shop_item;
<?php
$menu_name = 'main-menu';
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
?>
<ul class="nav">
<?php
$count = 0;
$submenu = true;
//Adds custom data field form
function wpse_259995_menu_custom_fields_fields( $id, $item, $depth, $args ) {
$_key = 'img_url';
$label = "Image URL";
$key = sprintf( 'menu-item-%s', $_key );
$id = sprintf( 'edit-%s-%s', $key, $item->ID );
$name = sprintf( '%s[%s]', $key, $item->ID );
$value = get_post_meta( $item->ID, $key, true );
$class = sprintf( 'field-%s', $_key );
add_filter('woocommerce_get_price_html', 'custom_price_html', 100, 2);
function custom_price_html($price, $product)
{
// if (is_singular('product')) {
// return $price;
// } else {
if ($product->is_type('simple')) {
if ($product->is_on_sale()) {
$price =
'
add_filter( 'get_user_option_admin_color', 'wpse_238039_set_admin_color' );
function wpse_238039_set_admin_color()
{
$current_user = wp_get_current_user();
// Check for the user role
if ( user_can( $current_user, 'dsm_teacher' ))
{
// Remove the Admin Color Scheme picker
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
add_action( 'wp_login', 'track_user_logins', 10, 2 );
function track_user_logins( $user_login, $user ){
if( $login_amount = get_user_meta( $user->id, 'login_amount', true ) ){
// They've Logged In Before, increment existing total by 1
update_user_meta( $user->id, 'login_amount', ++$login_amount );
} else {
// First Login, set it to 1
update_user_meta( $user->id, 'login_amount', 1 );
}
}
if (isset($_GET['activated']) && is_admin()){
$new_page_title = 'Parent Login';
$new_page_content = '';
$new_page_template = 'parent-login.php'; //ex. template-custom.php. Leave blank if you don't want a custom page template.
//don't change the code bellow, unless you know what you're doing
$page_check = get_page_by_title($new_page_title);
$new_page = array(
<header id="masthead" class="site-header">
<div class="site-branding">
<?php
the_custom_logo();
if ( is_front_page() && is_home() ) :
?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php
else :
?>
// ajax used in front end
add_action( 'init', 'dsm_script_enquer');
function dsm_script_enquer() {
wp_register_script( "dsm_js_front", get_template_directory_uri().'/js/main.js', array('jquery') );
wp_localize_script( 'dsm_js_front', 'dsmAjax',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'ajax_nonce' => wp_create_nonce('ajax_csrf_check'),
));
wp_enqueue_script( 'dsm_js_front' );
jQuery(document).ready(function(){
// Ajax for make primary address -- my account page
jQuery(".class-name").click(function(){
let class_id = $(this).attr('class-id');
jQuery.ajax({ //ajax request
url: dsmAjax.ajaxurl,
type: "POST",
data: {
'action':'dsmGetCustomPostTypes',