Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: Plugin by Divart
- * Plugin URI: https://www.divart.sk/
- * Description: This is the very first plugin I ever created.
- * Version: 1.0
- * Author: Martin z Divartu
- * Author URI: https://www.divart.sk/
- **/
- ?>
- <?php
- add_theme_support( 'woocommerce', array(
- 'thumbnail_image_width' => 550,
- 'single_image_width' => 722,
- ) );
- register_activation_hook( __FILE__, function() {
- add_option('Activated_Plugin','Plugin-Slug');
- /* activation code here */
- });
- add_action('admin_init','load_plugin');
- function load_plugin() {
- if(is_admin()&&get_option('Activated_Plugin')=='Plugin-Slug') {
- delete_option('Activated_Plugin');
- /* do some stuff once right after activation */
- }
- }
- function tutsplus_register_post_type() {
- // movies
- $labels = array(
- 'name' => __( 'DiSliders' , 'tutsplus' ),
- 'singular_name' => __( 'DiSlider' , 'tutsplus' ),
- 'add_new' => __( 'New Slide' , 'tutsplus' ),
- 'add_new_item' => __( 'Add New Slide' , 'tutsplus' ),
- 'edit_item' => __( 'Edit Slide' , 'tutsplus' ),
- 'new_item' => __( 'New Slide' , 'tutsplus' ),
- 'view_item' => __( 'View Slide' , 'tutsplus' ),
- 'search_items' => __( 'Search Slides' , 'tutsplus' ),
- 'not_found' => __( 'No Slide Found' , 'tutsplus' ),
- 'not_found_in_trash' => __( 'No Slides found in Trash' , 'tutsplus' ),
- );
- $args = array(
- 'labels' => $labels,
- 'has_archive' => true,
- 'public' => true,
- 'hierarchical' => false,
- 'supports' => array(
- 'title',
- 'thumbnail',
- ),
- 'rewrite' => array( 'slug' => 'dislider' ),
- 'show_in_rest' => true
- );
- register_post_type( 'divart_slider', $args );
- }
- add_action( 'init', 'tutsplus_register_post_type' );
- //gallery
- //gallery
- function gallery_register_post_type() {
- // movies
- $labels = array(
- 'name' => __( 'DiGalleries' , 'tutsplusss' ),
- 'singular_name' => __( 'DiGallery' , 'tutsplusss' ),
- 'add_new' => __( 'New Gallery' , 'tutsplusss' ),
- 'add_new_item' => __( 'Add New Gallery' , 'tutsplusss' ),
- 'edit_item' => __( 'Edit Gallery' , 'tutsplusss' ),
- 'new_item' => __( 'New Gallery' , 'tutsplusss' ),
- 'view_item' => __( 'View Gallery' , 'tutsplusss' ),
- 'search_items' => __( 'Search Gallery' , 'tutsplusss' ),
- 'not_found' => __( 'No Gallery Found' , 'tutsplusss' ),
- 'not_found_in_trash' => __( 'No Gallery found in Trash' , 'tutsplusss' ),
- );
- $args = array(
- 'labels' => $labels,
- 'has_archive' => true,
- 'public' => true,
- 'hierarchical' => false,
- 'supports' => array(
- 'title',
- 'thumbnail',
- ),
- 'rewrite' => array( 'slug' => 'gallery' ),
- 'show_in_rest' => true
- );
- register_post_type( 'divart_gallery', $args );
- }
- add_action( 'init', 'gallery_register_post_type' );
- //gallery
- //gallery
- //mainsettingspage
- // Register a theme options page
- add_filter( 'mb_settings_pages', function ( $settings_pages ) {
- $settings_pages[] = array(
- 'id' => 'dimainsettings',
- 'option_name' => 'DiSettings',
- 'menu_title' => 'DiSettings',
- 'icon_url' => 'dashicons-edit',
- 'style' => 'no-boxes',
- 'columns' => 1,
- 'tabs' => array(
- 'general' => 'General Settings',
- 'faq' => 'FAQ & Help',
- ),
- );
- return $settings_pages;
- });
- //mainsettingspage
- add_filter( 'rwmb_meta_boxes', 'meta_box_group_demo_register' );
- function meta_box_group_demo_register( $meta_boxes ) {
- //mainsettingspage
- $meta_boxes[] = array(
- 'id' => 'general',
- 'title' => 'General',
- 'settings_pages' => 'dimainsettings',
- 'tab' => 'general',
- 'fields' => array(
- array(
- 'name' => 'Logo',
- 'id' => 'logo',
- 'type' => 'file_input',
- ),
- array(
- 'name' => 'Meta Description',
- 'id' => 'meta_description',
- 'type' => 'textarea',
- 'placeholder' => 'Meta Description',
- 'rows' => 4,
- ),
- array(
- 'name' => 'Meta Keywords',
- 'id' => 'meta_keywords',
- 'type' => 'textarea',
- 'placeholder' => 'Meta Description',
- 'rows' => 4,
- ),
- ),
- );
- $meta_boxes[] = array(
- 'id' => 'info',
- 'title' => 'Theme Info',
- 'settings_pages' => 'dimainsettings',
- 'tab' => 'faq',
- 'fields' => array(
- array(
- 'type' => 'custom_html',
- 'std' => 'Having questions? Check out our documentation',
- ),
- ),
- );
- //mainsettingspage
- //gallery
- //gallery
- $meta_boxes[] = array(
- 'title' => 'Divart Gallery',
- 'post_types' => ['divart_gallery'],
- 'fields' => array(
- array(
- 'id' => 'digallery',
- // Group field
- 'type' => 'group',
- // Clone whole group?
- 'clone' => false,
- // Drag and drop clones to reorder them?
- 'sort_clone' => false,
- // Sub-fields
- 'collapsible' => false,
- 'group_title' => 'Gallery', // ID of the subfield
- 'save_state' => true,
- 'fields' => array(
- array(
- 'name' => 'Add Gallery',
- 'id' => 'gallimage',
- 'type' => 'image_advanced',
- // Delete image from Media Library when remove it from post meta?
- // Note: it might affect other posts if you use same image for multiple posts
- 'force_delete' => false,
- // Do not show how many images uploaded/remaining.
- 'max_status' => 'false',
- // Image size that displays in the edit page. Possible sizes small,medium,large,original
- 'image_size' => 'thumbnail',
- ),
- array(
- 'name' => 'Background Color',
- 'id' => 'bgcolor',
- 'type' => 'color',
- ),
- // Nested group level 2
- ),
- ),
- ),
- );
- //gall settings
- $meta_boxes[] = array(
- 'title' => 'Page Settings',
- 'post_types' => ['divart_gallery'],
- 'fields' => array(
- array(
- 'id' => 'disettinggallery',
- // Group field
- 'type' => 'group',
- // Clone whole group?
- 'clone' => false,
- // Drag and drop clones to reorder them?
- 'sort_clone' =>false,
- // Sub-fields
- 'collapsible' => false,
- 'save_state' => true,
- 'fields' => array(
- array(
- 'name' => 'Show Title',
- 'id' => 'hidetitlegall',
- 'type' => 'checkbox',
- ),
- array(
- 'name' => 'Show Menu',
- 'id' => 'hidemenugall',
- 'type' => 'checkbox',
- ),
- ),
- ),
- ),
- );
- //gall settings
- //gallery
- //gallery
- $meta_boxes[] = array(
- 'title' => 'Divart Slider',
- 'post_types' => ['divart_slider'],
- 'fields' => array(
- array(
- 'id' => 'disliders',
- // Group field
- 'type' => 'group',
- // Clone whole group?
- 'clone' => true,
- // Drag and drop clones to reorder them?
- 'sort_clone' => true,
- // Sub-fields
- 'collapsible' => true,
- 'group_title' => 'Slide {#}', // ID of the subfield
- 'save_state' => true,
- 'fields' => array(
- array(
- 'name' => 'Background Image',
- 'id' => 'bgimg',
- 'type' => 'url',
- ),
- array(
- 'name' => 'Background Color',
- 'id' => 'bgcolor',
- 'type' => 'color',
- ),
- array(
- 'name' => 'Text Color',
- 'id' => 'textcolorr',
- 'type' => 'color',
- ),
- array(
- 'name' => 'Text Align',
- 'id' => 'textalign',
- 'type' => 'select',
- // Array of 'value' => 'Label' pairs
- 'options' => array(
- 'flex-start' => 'left',
- 'center' => 'center',
- 'flex-end' => 'right',
- ),
- // Allow to select multiple value?
- 'multiple' => false,
- // Placeholder text
- 'placeholder' => 'Text Align',
- // Display "Select All / None" button?
- 'select_all_none' => true,
- ),
- array(
- 'name' => 'Select style',
- 'id' => 'selectstyle',
- 'type' => 'select',
- // Array of 'value' => 'Label' pairs
- 'options' => array(
- 'spartan' => 'spartan',
- 'julius' => 'julius',
- 'archivo' => 'archivo',
- 'fashion' => 'fashion',
- 'amatic' => 'amatic',
- ),
- // Allow to select multiple value?
- 'multiple' => false,
- // Placeholder text
- 'fashion' => 'fashion',
- // Display "Select All / None" button?
- 'select_all_none' => true,
- ),
- array(
- 'name' => 'Main Header',
- 'id' => 'mainh',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Sub Header',
- 'id' => 'subh',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Main Text',
- 'id' => 'maintext',
- 'type' => 'textarea',
- 'rows' => 2,
- ),
- array(
- 'name' => 'Icon Text',
- 'id' => 'icontext',
- 'type' => 'textarea',
- 'rows' => 2,
- ),
- array(
- 'name' => 'Show Icon',
- 'id' => 'showicontext',
- 'type' => 'checkbox',
- ),
- array(
- 'name' => 'Add Gallery',
- 'id' => 'gallimage',
- 'type' => 'image_advanced',
- // Delete image from Media Library when remove it from post meta?
- // Note: it might affect other posts if you use same image for multiple posts
- 'force_delete' => false,
- // Do not show how many images uploaded/remaining.
- 'max_status' => 'false',
- // Image size that displays in the edit page. Possible sizes small,medium,large,original
- 'image_size' => 'thumbnail',
- ),
- array(
- 'name' => 'Gallery Name',
- 'id' => 'gallname',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Gallery Icon',
- 'id' => 'showgallicon',
- 'type' => 'checkbox',
- ),
- // Nested group level 2
- array(
- 'name' => 'Buttons',
- 'id' => 'sub_group_btn',
- 'type' => 'group',
- 'clone' => true,
- 'fields' => array(
- // Normal field (cloned)
- array(
- 'name' => 'Button Text',
- 'id' => 'buttontext',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Button URL',
- 'id' => 'btnurl',
- 'type' => 'url',
- ),
- ),
- ),
- ),
- ),
- ),
- );
- $meta_boxes[] = array(
- 'title' => 'Divart Post Hero Settings',
- 'post_types' => ['post'],
- 'fields' => array(
- array(
- 'id' => 'dipost',
- // Group field
- 'type' => 'group',
- // Clone whole group?
- 'clone' => false,
- // Drag and drop clones to reorder them?
- 'sort_clone' =>false,
- // Sub-fields
- 'collapsible' => false,
- 'group_title' => 'Slidee {#}', // ID of the subfield
- 'save_state' => true,
- 'fields' => array(
- array(
- 'name' => 'Hide Page Title',
- 'id' => 'hidepagetitle',
- 'type' => 'checkbox',
- ),
- array(
- 'name' => 'Select style',
- 'id' => 'selectstyle',
- 'type' => 'select',
- // Array of 'value' => 'Label' pairs
- 'options' => array(
- 'spartan' => 'spartan',
- 'julius' => 'julius',
- 'archivo' => 'archivo',
- 'fashion' => 'fashion',
- 'amatic' => 'amatic',
- ),
- // Allow to select multiple value?
- 'multiple' => false,
- // Placeholder text
- 'julius' => 'julius',
- // Display "Select All / None" button?
- 'select_all_none' => true,
- ),
- array(
- 'name' => 'Main Header',
- 'id' => 'mainh',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Sub Header',
- 'id' => 'subh',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Main Text',
- 'id' => 'maintext',
- 'type' => 'textarea',
- 'rows' => 4,
- ),
- array(
- 'name' => 'Text Color',
- 'id' => 'textcolorr',
- 'type' => 'color',
- ),
- array(
- 'name' => 'Buttons',
- 'id' => 'sub_group_btn',
- 'type' => 'group',
- 'clone' => true,
- 'fields' => array(
- // Normal field (cloned)
- array(
- 'name' => 'Button Text',
- 'id' => 'buttontext',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Button URL',
- 'id' => 'btnurl',
- 'type' => 'url',
- ),
- ),
- ),
- ),
- ),
- ),
- );
- $meta_boxes[] = array(
- 'title' => 'Divart Page Hero Settings',
- 'post_types' => ['page'],
- 'fields' => array(
- array(
- 'id' => 'dipage',
- // Group field
- 'type' => 'group',
- // Clone whole group?
- 'clone' => false,
- // Drag and drop clones to reorder them?
- 'sort_clone' =>false,
- // Sub-fields
- 'collapsible' => false,
- 'group_title' => 'Slidee {#}', // ID of the subfield
- 'save_state' => true,
- 'fields' => array(
- array(
- 'name' => 'Hide Page Title',
- 'id' => 'hide_pagetitle',
- 'type' => 'checkbox',
- ),
- array(
- 'name' => 'Select style',
- 'id' => 'selectstyle',
- 'type' => 'select',
- // Array of 'value' => 'Label' pairs
- 'options' => array(
- 'spartan' => 'spartan',
- 'julius' => 'julius',
- 'archivo' => 'archivo',
- 'fashion' => 'fashion',
- 'amatic' => 'amatic',
- ),
- // Allow to select multiple value?
- 'multiple' => false,
- // Placeholder text
- 'julius' => 'julius',
- // Display "Select All / None" button?
- 'select_all_none' => true,
- ),
- array(
- 'name' => 'Main Header',
- 'id' => 'mainh',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Sub Header',
- 'id' => 'subh',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Main Text',
- 'id' => 'maintext',
- 'type' => 'textarea',
- 'rows' => 4,
- ),
- array(
- 'name' => 'Text Color',
- 'id' => 'textcolorr',
- 'type' => 'color',
- ),
- array(
- 'name' => 'Buttons',
- 'id' => 'sub_group_btn',
- 'type' => 'group',
- 'clone' => true,
- 'fields' => array(
- // Normal field (cloned)
- array(
- 'name' => 'Button Text',
- 'id' => 'buttontext',
- 'type' => 'text',
- ),
- array(
- 'name' => 'Button URL',
- 'id' => 'btnurl',
- 'type' => 'url',
- ),
- ),
- ),
- ),
- ),
- ),
- );
- $meta_boxes[] = array(
- 'title' => 'Page Settings',
- 'post_types' => ['divart_slider'],
- 'fields' => array(
- array(
- 'id' => 'disettingpage',
- // Group field
- 'type' => 'group',
- // Clone whole group?
- 'clone' => false,
- // Drag and drop clones to reorder them?
- 'sort_clone' =>false,
- // Sub-fields
- 'collapsible' => false,
- 'save_state' => true,
- 'fields' => array(
- array(
- 'name' => 'Show Title',
- 'id' => 'hidetitle',
- 'type' => 'checkbox',
- ),
- array(
- 'name' => 'Show Menu',
- 'id' => 'hidemenu',
- 'type' => 'checkbox',
- ),
- ),
- ),
- ),
- );
- // settings
- // settings
- $meta_boxes[] = array(
- 'title' => 'Page Settings',
- 'post_types' => ['divart_slider']['page=settings'],
- 'fields' => array(
- array(
- 'id' => 'disettingpageaa',
- // Group field
- 'type' => 'group',
- // Clone whole group?
- 'clone' => false,
- // Drag and drop clones to reorder them?
- 'sort_clone' =>false,
- // Sub-fields
- 'collapsible' => false,
- 'save_state' => true,
- 'fields' => array(
- array(
- 'name' => 'Show Title',
- 'id' => 'hidetitle',
- 'type' => 'checkbox',
- ),
- array(
- 'name' => 'Show Menu',
- 'id' => 'hidemenu',
- 'type' => 'checkbox',
- ),
- ),
- ),
- ),
- );
- // settings
- // settings
- return $meta_boxes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement