Skip to content

Instantly share code, notes, and snippets.

View iamchetanp's full-sized avatar
🏠
Working from home

Chetan Prajapati iamchetanp

🏠
Working from home
View GitHub Profile
@iamchetanp
iamchetanp / (1) tooltip.html
Last active December 27, 2017 19:12
How to Create Tooltip with Icon
<div class="tooltip_wrap">
<strong class="tooltip">
<a href="https://www.chetanprajapati.com/">
<i class="icon icon_clock"></i>
</a>
<span class="tooltip-content">
<span class="tooltip-text">
<span class="tooltip-inner">
Monday, 8am - 8pm<br>
Tuesday, 8am - 8pm<br>
@iamchetanp
iamchetanp / disable_comment_moderate_editor.php
Created March 8, 2018 21:22
Remove capability of moderate comments for editor.
/**
* Remove capability of moderate comments for editor.
*/
function cp_remove_aprove_comment_capability_for_editor() {
// Get the role object.
$editor = get_role( 'editor' );
// Removes capabiity to moderate comments.
$editor->remove_cap( 'moderate_comments' );
@iamchetanp
iamchetanp / script.js
Last active June 8, 2018 20:20
Vertical Toggle Divi Menu
<script type="text/javascript">
(function($) {
$(window).load(function() {
$('#top-menu > .menu-item-has-children > a').attr('href', '#');
$('#top-menu > .menu-item-has-children > a').each(function() {
$(this).next('.sub-menu').addClass('hide');
});
$('#top-menu > .menu-item-has-children > a').click(function(event) {
event.preventDefault();
@iamchetanp
iamchetanp / seopress-titles-desc.php
Last active August 30, 2018 19:00
To strp shortcodes form SEOPress plugin meta description.
/**
* To strp shortcodes form SEOPress plugin meta description.
*
* @param string $html Meta description text.
*
* @return string Meta description text without shortcode tags.
*/
function cp_strip_shortcodes( $html ) {
return strip_shortcodes( $html );
}
@iamchetanp
iamchetanp / wordpress-menu-shortcode.php
Last active August 26, 2018 11:28
Create shortcode to get WordPress menu in HTML format.
/**
* Create shortcode to get WordPress menu in HTML format.
* How to use? [cp_wp_menu name="Main Menu"]
*
* @param array $atts Array of attributes.
*
* @return string HTML menu.
*/
function cp_wp_menu_shortcode( $atts ) {
$menu = shortcode_atts( array(
@iamchetanp
iamchetanp / disable-scrolltop-mulitpage-caldera-form.js
Created September 26, 2018 21:43
Disable scrollTop for multipage caldera form.
jQuery(document).on('click', '.form-page', function(e){
var clicked = jQuery(this),
page_box = clicked.closest('.caldera-form-page'),
form = clicked.closest('form.caldera_forms_form'),
form_id = form.attr( 'id' ),
instance = form.data('instance'),
current_page = form.find('.caldera-form-page:visible').data('formpage'),
page = page_box.data('formpage') ? page_box.data('formpage') : clicked.data('page') ,
breadcrumb = jQuery('.breadcrumb[data-form="caldera_form_' + instance + '"]'),
@iamchetanp
iamchetanp / .htaccess
Last active December 16, 2018 21:28
Reditect rule for redirecting HTTP to HTTS (Apache) htaccess
# Redirect HTTP URLs to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@iamchetanp
iamchetanp / .htaccess
Created December 16, 2018 21:33
Redirect non-www URLs to www with https (Apache)
# Redirect non-www URLs to www with https
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
@iamchetanp
iamchetanp / login.php
Last active March 19, 2019 10:03
Better WordPress Login Page
<?php
/**
* CSS rules for WordPress Login page.
*
* @package ChetanP
*/
/**
* CSS for wp-login.php page
*/
@iamchetanp
iamchetanp / functions.php
Created June 26, 2019 10:52
Title function for WordPress
/**
* Return title based on current page, post, taxonomy, post type, category, tag etc.
*/
function cpdivi_title() {
if ( is_home() ) {
$page_for_posts = get_option( 'page_for_posts' );
$title = sprintf( __( '%s', 'cpdivi' ), get_the_title( $page_for_posts ) );
} elseif ( is_category() ) {
/* translators: 1: category title. */
$title = sprintf( __( 'Category: %s', 'cpdivi' ), single_cat_title( '', false ) );