Skip to content

Instantly share code, notes, and snippets.

View softiconic's full-sized avatar

Softiconic softiconic

View GitHub Profile
@softiconic
softiconic / custom.css
Last active December 2, 2023 18:47
Display a Google Map in grayscale.
#map
{
filter: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><filter id="g"><feColorMatrix type="matrix" values="0.3 0.3 0.3 0 0 0.3 0.3 0.3 0 0 0.3 0.3 0.3 0 0 0 0 0 1 0"/></filter></svg>#g');
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
filter: progid:DXImageTransform.Microsoft.BasicImage(grayScale=1);
}
@softiconic
softiconic / share.html
Last active December 2, 2023 18:46
Create a custom share link with specified title and text message.
<a title="Share on Facebook" target="_blank" rel="noopener noreferrer"
href="https://www.facebook.com/sharer/sharer.php?u=url-here"> Facebook </a>
<a title="Share on Twitter" target="_blank" rel="noopener noreferrer"
href="https://twitter.com/intent/tweet?text=text here"> Twitter </a>
<a title="Share on LinkedIn" target="_blank" rel="noopener noreferrer"
href="https://www.linkedin.com/shareArticle?mini=true&amp;url=#/&amp;title=Title&amp;summary=
Test here&amp;source=LinkedIn">LinkedIn </a>
@softiconic
softiconic / router-index.js
Last active December 2, 2023 18:46
In Vue.js, scroll from the top to the bottom of a routed page.
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return { x: 0, y: 0 }
}
}
or try,
@softiconic
softiconic / custom.html
Last active December 2, 2023 18:45
Customize file upload functionality for input elements.
.upload-btn-wrapper input[type=file] {
position: absolute;
font-size: 14px;
top: 0;
color: #141414;
right: 0;
}
input[type="file"]::-webkit-file-upload-button {
background: transparent;
border: 0;
@softiconic
softiconic / custom.js
Last active December 2, 2023 18:45
JavaScript filter functionality.
var container = $('.filter-container');
var elements = $('.filter-container > *');
var buttons = $('.filter-buttons a');
// set all elements active
elements.addClass('selected elements');
// remove select all filter
$('.filter-buttons a.select-all').remove();
buttons.click(function(){
// set all elements inactive by first call
@softiconic
softiconic / gist:890cfd3ced2ecabed1fd20a196b14ca3
Last active December 2, 2023 18:44
Create a custom post with categories - Wordpress
//career post
function create_job() {
register_post_type( 'job',
array(
'labels' => array(
'name' => __( 'Career' , 'softiconic'),
'singular_name' => __( 'Career' , 'softiconic'),
'add_new' => __('Add New Career', 'softiconic'),
'edit_item' => __('Edit Career', 'softiconic'),
'new_item' => __('New Career', 'softiconic'),
@softiconic
softiconic / config.js
Last active December 2, 2023 18:44
Allow the video tag in CKEditor.
CKEDITOR.editorConfig = function (config) {
config.allowedContent = true;
};
@softiconic
softiconic / custom.php
Last active December 2, 2023 18:43
Loop through custom posts filtered by custom taxonomies in WordPress.
<?php
// Get all the categories
$categories = get_terms( 'sccategory' );
// Loop through all the returned terms
foreach ( $categories as $category ):
// set up a new query for each category, pulling in related posts.
$services = new WP_Query(
array(
@softiconic
softiconic / function.php
Last active December 2, 2023 18:43
Include Elementor anchor with an offset.
add_action( 'wp_footer', function() {
if ( ! defined( 'ELEMENTOR_VERSION' ) ) {
return;
}
?>
<script>
window.addEventListener('elementor/frontend/init', function() {
elementorFrontend.hooks.addFilter( 'frontend/handlers/menu_anchor/scroll_top_distance', function( scrollTop ) {
return scrollTop - 180;
@softiconic
softiconic / function.php
Last active December 2, 2023 18:42
Track WordPress post views without using a plugin.
function gt_get_post_view() {
$count = get_post_meta( get_the_ID(), 'post_views_count', true );
return "$count views";
}
function gt_set_post_view() {
$key = 'post_views_count';
$post_id = get_the_ID();
$count = (int) get_post_meta( $post_id, $key, true );
$count++;
update_post_meta( $post_id, $key, $count );