Skip to content

Instantly share code, notes, and snippets.

View mdjwel's full-sized avatar
🎯
Focusing

Eh Jewel mdjwel

🎯
Focusing
View GitHub Profile
<?php
if( class_exists( 'WooCommerce' ) ) {
// WooCommerce stylesheets
wp_deregister_style( 'woocommerce-layout' );
wp_deregister_style( 'woocommerce-smallscreen' );
wp_deregister_style( 'tinvwl' );
if( is_shop() || is_tax( 'product_cat') || is_singular( 'product') || is_tax( 'product_tag') || is_checkout() || is_cart() || is_account_page() ) {
wp_enqueue_style( 'woocommerce-general' );
} else {
@mdjwel
mdjwel / get_id_by_page_template.php
Created July 24, 2019 09:48
Get the page id by page template
<?php
function filix_get_page_template_id( $template = 'page-job-apply-form.php' ) {
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => $template
));
foreach($pages as $page){
$page_id = $page->ID;
}
return $page_id;
@mdjwel
mdjwel / string_manipulations_wp.php
Created April 5, 2019 10:27
Here, I'm listing some functions that do string manipulation in WordPress.
<?php
/**
* Get a specific html tag from content
* @return a specific HTML tag from the loaded content
*/
function rogan_get_html_tag( $tag = 'blockquote', $content = '' ) {
$dom = new DOMDocument();
$dom->loadHTML($content);
$divs = $dom->getElementsByTagName( $tag );
$i = 0;
@mdjwel
mdjwel / cf7_forms_array.php
Last active February 5, 2019 08:00
Contact Form 7 Post Title Lists
<?php
if ( ! function_exists( '_get_contact_form_7_posts' ) ) :
function _get_contact_form_7_posts(){
$args = array( 'post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1 );
$catlist = [];
if( $categories = get_posts( $args ) ){
@mdjwel
mdjwel / Elementor_button_styles.php
Last active October 26, 2019 10:10
Elementor widget development snippets
<?php
/// -------------------- Buttons ----------------------------
$this->start_controls_section(
'buttons_sec',
[
'label' => __( 'Buttons', 'saasland-core' ),
]
);
$repeater = new \Elementor\Repeater();
@mdjwel
mdjwel / banner_title.php
Created January 19, 2019 09:05
Display theme banner title based on what the page is
<?php
// Banner Title
function saasland_banner_title() {
$opt = get_option('saasland_opt');
if(is_home()) {
$blog_title = !empty($opt['blog_title']) ? $opt['blog_title'] : esc_html__('Blog', 'appland');
echo esc_html($blog_title);
}
elseif(is_page() || is_single()) {
the_title();
@mdjwel
mdjwel / ul_pagination.php
Last active July 21, 2022 17:52
Apply Custom ul>li Pagination in WordPress
<?php
function saasland_pagination() {
global $wp_query;
if ( $wp_query->max_num_pages <= 1 ) return;
$big = 999999999; // need an unlikely integer
$pages = paginate_links( array(
@mdjwel
mdjwel / login_form.php
Created December 17, 2018 12:18
Custom user login form
<form name="loginform" id="loginform" action="<?php echo esc_url(home_url('/')); ?>wp-login.php" method="post" class="sign_form">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12 form-group">
<input class="form-control" id="name_email" name="log" type="text"
placeholder="Username" onfocus="this.placeholder=''"
onblur="this.placeholder='Username'">
</div>
<div class="col-md-6 col-sm-6 col-xs-12 form-group">
<input class="form-control" type="password" name="pwd" id="pass"
placeholder="Password" onfocus="this.placeholder=''"
@mdjwel
mdjwel / walker_nave_menu_class_extend.php
Last active January 8, 2019 09:15
Walker_Nav_Menu class extending to match custom dropdown menu markup
<?php
/**
* WP Bootstrap Navwalker
*
* @package WP-Bootstrap-Navwalker
*/
/*
* Class Name: Gullu_Nav_Navwalker
*/
@mdjwel
mdjwel / wp_next_prev_post_links.php
Created December 3, 2018 06:03
Next Previous Post Link
<?php
$prev_post = get_previous_post();
$next_post = get_next_post();
if($prev_post) : ?>
<a href="<?php echo get_permalink($prev_post->ID) ?>" class="prev"><i class="ti-arrow-left"></i>
<?php esc_html_e('Prev Project', 'saasland') ?>
</a>
<?php endif; ?>
<?php if($next_post) : ?>
<a href="<?php echo get_permalink($next_post->ID) ?>" class="next">Next Project<i class="ti-arrow-right"></i></a>