Skip to content

Instantly share code, notes, and snippets.

@Mamikonars
Mamikonars / functions.php
Created August 19, 2022 17:56
WordPress subscription form
wp_enqueue_script( 'gym-subscribe', get_template_directory_uri() . '/assets/js/subscribe-form.js', array('jquery'), THEME_VERSION, true );
wp_localize_script( 'gym-subscribe', 'subscribe_form_object', array(
'url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'subscribe-form-nonce' ),
) );
@Mamikonars
Mamikonars / ajax-form-functions.php
Last active August 19, 2022 19:38
WordPress ajax form
<?php
add_action( 'wp_ajax_ajax_form_action', 'ajax_action_callback' );
add_action( 'wp_ajax_nopriv_ajax_form_action', 'ajax_action_callback' );
function ajax_action_callback() {
// errors array
$errors = [];
@Mamikonars
Mamikonars / customizer.php
Created August 17, 2022 14:36
Customizer settings
<?php
function gym_castomization($wp_customize) {
//add panel
$wp_customize->add_panel('gym_panel', array(
'priority' => 30,
'capability' => 'edit_theme_options',
'title' => esc_html__('Gym settings', 'gym'),
'description' => esc_html__('Page settings', 'gym'),
));
@Mamikonars
Mamikonars / options-script.js
Created August 7, 2022 16:57
Image upload on options WP page
jQuery( document ).ready(function($) {
//image option
$('body').on( 'click', '.muna-upl', function(e){
e.preventDefault();
var button = $(this),
custom_uploader = wp.media({
title: 'Insert image',
library : {
// uploadedTo : wp.media.view.settings.post.id, // attach to the current post?
type : 'image'
$content[] = '#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' {
width: ' . $width . ';
}
#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' .
$this->html_class_prefix . 'section-header {
border-top-color: ' . $this->options[ $this->name_prefix . 'color' ] . ';
}
#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question {
#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section.' .
$this->html_class_prefix . 'section-start-page .' . $this->html_class_prefix . 'section-header *,
#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'section.' .
$this->html_class_prefix . 'section-start-page .' . $this->html_class_prefix . 'section-header .' . $this->html_class_prefix .
'section-title-row {
color: ' . $this->options[ $this->name_prefix . 'start_page_text_color' ] . ';
}
#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' input.' . $this->html_class_prefix . 'question-input ~
.' . $this->html_class_prefix . 'input-underline,
#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question {
border-left-color: ' . $this->options[ $this->name_prefix . 'color' ] . ';
}
#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' .' . $this->html_class_prefix . 'question {
' . ( $this->options[ $this->name_prefix . 'logo' ] != '' ? 'padding-bottom: 50px;' : '' ) . '
}
#' . $this->html_class_prefix . 'container-' . $this->unique_id_in_class . ' input.' . $this->html_class_prefix . 'question-input {
font-size: ' . $this->options[ $this->name_prefix . 'answer_font_size' ] . 'px;