Skip to content

Instantly share code, notes, and snippets.

@Gori4ka
Gori4ka / all_fields.php
Last active April 17, 2017 21:39
FHandler
array(
array(
'label' => __('Field[ input ] Type[ text ]', 'fh'),
'type' => 'input',
'field' => array(
'type' => 'text',
'name' => 'fh_text',
'class' => 'widefat',
'value' => get_option('fh_text')
)
@Gori4ka
Gori4ka / ajax-post-loader.js
Last active April 20, 2017 09:49
index with page blog
/*
* Ajax post loader
**/
if (1) {
$('main').on('click', '.blog-page-mehr', function (e) {
e.preventDefault();
var $text = $(this).html(),
$this = $(this),
$data_attr = $.parseJSON($(this).attr('data-ajax-more')),
$data = {};
@Gori4ka
Gori4ka / js-ajax-form.js
Last active April 19, 2017 09:50
WordPress call ajax
if (1) {
$('.main').on('submit', 'selector', function (e) {
var $form = $(this);
e.preventDefault();
wp.ajax.send('action_name', {
success: function (response) {
$('.alert', $form).addClass('succes').text(response.message);
$($form)[0].reset();
setTimeout(function () {
$('.alert', $form).removeClass('succes');
@Gori4ka
Gori4ka / shortcode-video.php
Created January 11, 2019 22:27
fix. Add parameter mute. So in chrome you can do automatic video playback.
<?php
add_shortcode( 'video', function ( $atts, $content )
{
$output = wp_video_shortcode( $atts, $content );
if( ! isset( $atts['muted'] ) || ! wp_validate_boolean( $atts['muted'] ) )
return $output;
if( false !== stripos( $output, ' muted="1"' ) )
return $output;
@Gori4ka
Gori4ka / example-ajax-enqueue.php
Last active September 10, 2020 16:32
Simple WordPress Ajax Example
<?php
function example_ajax_enqueue() {
// Enqueue javascript on the frontend.
wp_enqueue_script(
'example-ajax-script',
get_template_directory_uri() . '/js/simple-ajax-example.js',
array('jquery','wp-util')
);
@Gori4ka
Gori4ka / acf-pagination.php
Created January 14, 2020 20:36 — forked from kisabelle/acf-pagination.php
ACF Repeater Field Pagination
<?php
/*
* Paginate Advanced Custom Field repeater
*/
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
$page = 1;
}
@Gori4ka
Gori4ka / admin.css
Created October 4, 2020 19:23 — forked from prasetyop/admin.css
Flexible Content Preview Pop Up
.acf-fc-popup .preview {
position: absolute;
right: 100%;
margin-right: 0px;
top: 0;
background: #383c44;
min-height: 100%;
border-radius: 5px;
align-content: center;
display: grid;
@Gori4ka
Gori4ka / Include Tags In Search
Created November 25, 2020 11:01 — forked from spencejs/Include Tags In Search
Include Tags In Wordpress Search
@Gori4ka
Gori4ka / bradvin.social.share.urls.txt
Created December 27, 2020 11:55 — forked from HoldOffHunger/bradvin.social.share.urls.txt
Social Share URL's (Summary)
https://www.facebook.com/sharer.php?u={url}
https://www.facebook.com/dialog/share?app_id={app_id}&display={page_type}&href={url}&redirect_uri={redirect_url}
https://reddit.com/submit?url={url}&title={title}
https://twitter.com/intent/tweet?url={url}&text={title}&via={user_id}&hashtags={hash_tags}
https://www.linkedin.com/sharing/share-offsite/?url={url}
https://api.whatsapp.com/send?phone={phone_number}&text={title}%20{url}
https://www.tumblr.com/widgets/share/tool?canonicalUrl={url}&title={title}&caption={text}&tags={hash_tags}
http://pinterest.com/pin/create/button/?url={url}
https://www.blogger.com/blog-this.g?u={url}&n={title}&t={text}
https://www.evernote.com/clip.action?url={url}&title={title}
@Gori4ka
Gori4ka / serve-side-block.js
Created July 18, 2021 22:29 — forked from Shelob9/serve-side-block.js
Example Gutenberg block with server-side rendering. Gutenberg edit() block creates interface. Gutenberg saves settings automatically, the PHP function passed as `render_callback` to `register_block_type` is used to create HTML for front-end rendering of block.
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const el = wp.element.createElement;
registerBlockType( 'hiRoy/serverSide', {
title: __( 'Server Side Block', 'text-domain' ),
icon: 'networking',
category: 'common',
attributes: {