Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
<script type="text/javascript">
jQuery(document).ready(function() {
// Hide the div
jQuery('#reveal').hide();
jQuery('.rv_button').click(function(e){
e.preventDefault();jQuery("#reveal").slideToggle();
jQuery('.rv_button').toggleClass('opened closed');
});
});
</script>
<style type="text/css">
.rv_button.closed:after {content:"\33";}
.rv_button.opened:after{content:"\32";}
</style>
@dexit
dexit / wp-property-hive-vebra-import-new-build-fix.php
Created November 19, 2019 23:23
Wordpress plugin Property Hive Vebra Import build fix
add_action( "propertyhive_property_imported_vebra_xml", "set_new_build_marketing_flag", 10, 2 );
function set_new_build_marketing_flag($post_id, $property)
{
if ( isset($property->newbuild) && $property->newbuild == true )
{
update_post_meta( $post_id, '_new_build', '1' );
}
}
@dexit
dexit / woo-select-all-single-selects.js
Created November 19, 2019 23:30
WooCommerce select first option on all single variation dropdowns
let selectFields = document.querySelectorAll(".wc-default-select");
selectFields.forEach( (item, index) => {
let itemLen = item.length;
// check length console.log(brand);
if (itemLen == 2){
// set index
item.selectedIndex = 1;
//console.log("selected");
}else{
@dexit
dexit / wp-member-only-shortcode.php
Created November 20, 2019 19:38
Simple Member only shortcode for Wordpress
function member_only_shortcode($atts, $content = null)
{
if (is_user_logged_in() && !is_null($content) && !is_feed()) {
return $content;
}
}
add_shortcode('member_only', 'member_only_shortcode');
@dexit
dexit / child-functions-php-snippet.php
Created November 21, 2019 12:32 — forked from lots0logs/child-functions-php-snippet.php
WordPress :: Divi Builder :: Contact Form Module :: Change the submit button text
<?php
/* DON'T copy the first line (above) if your functions.php already has it.
* ---------------------------------------------------------------------- */
function my_et_theme_setup() {
if ( class_exists( 'ET_Builder_Module_Contact_Form' ) ) {
get_template_part( 'my-main-modules' );
$et_pb_contact = new My_ET_Builder_Module_Contact_Form();
remove_shortcode('et_pb_contact');
@dexit
dexit / wp-ph-vebra-import-mark-new-build.php
Last active November 22, 2019 10:39
Wordpress Property Hive mark imported NEW BUILD propreties from VEBRA to later re-use
add_action( "propertyhive_property_imported_vebra_api_xml", "set_new_build_marketing_flag", 10, 2 );
function set_new_build_marketing_flag($post_id, $property)
{
$property_attributes = $property->attributes();
if ( (string)$property_attributes['database'] == '15' || (isset($property->newbuild) && $property->newbuild == true) )
{
update_post_meta( $post_id, '_new_build', '1' );
}
else
{
@dexit
dexit / Recent Custom Post Type SHortcode.php
Created February 28, 2020 12:04
Recent Custom Post Type SHortcode
<?php
// recent posts shortcode
// @
function dexit_project_list($atts, $content = null) {
global $post;
extract(shortcode_atts(array(
'post_type' => 'project',
'post_status' => 'publish',
@dexit
dexit / create-admin-user.php
Created April 16, 2020 09:08 — forked from wpscholar/create-admin-user.php
Create a new admin user in WordPress via code. Drop this file in the mu-plugins directory and update the variables, then load a page in WordPress to create the user. Remove the file when done.
<?php
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = '[email protected]';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
@dexit
dexit / pc-menu.js
Created April 28, 2020 20:57 — forked from neilgee/pc-menu.js
WooCommerce Accordion Style Expand/Collapse Product Category Menu
jQuery(document).ready(function($) {
/**
* WooCommerce Product Category Accordion jQuery Menu
* @link https://wpbeaches.com/woocommerce-accordion-style-expand-collapse-product-category-menu/
*/
if ($('ul.product-categories').length > 0) {
// Set variables