Advertisement
designbymerovingi

Custom Scratch Card Plugin Example

Jan 30th, 2016
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.23 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Plugin Name: Custom Scratch Card Templates
  4.  * Description: Adds custom templates to the myCRED Scratch Card add-on.
  5.  * Version: 1.0
  6.  * Tags: mycred, scratch card, template
  7.  * Author: Author Name
  8.  * Author URI: http://www.authorswebsite.com
  9.  * Requires at least: WP 3.8
  10.  * Tested up to: WP 4.4.1
  11.  * License: Copyrighted
  12.  *
  13.  * Copyright © 2016 Author Name
  14.  *
  15.  * Permission is hereby granted, to the licensed domain to install and run this
  16.  * software and associated documentation files (the "Software") for an unlimited
  17.  * time with the followning restrictions:
  18.  *
  19.  * - This software is only used under the domain name registered with the purchased
  20.  *   license though the myCRED website (mycred.me). Exception is given for localhost
  21.  *   installations or test enviroments.
  22.  *
  23.  * - This software can not be copied and installed on a website not licensed.
  24.  *
  25.  * - This software is supported only if no changes are made to the software files
  26.  *   or documentation. All support is voided as soon as any changes are made.
  27.  *
  28.  * - This software is not copied and re-sold under the current brand or any other
  29.  *   branding in any medium or format.
  30.  *
  31.  * The above copyright notice and this permission notice shall be included in
  32.  * all copies or substantial portions of the Software.
  33.  *
  34.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  35.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  36.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  37.  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  38.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39.  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  40.  * THE SOFTWARE.
  41.  */
  42. define( 'CUSTOM_SCRATCH_TEMPLATE_VERSION', '1.0' );
  43. define( 'CUSTOM_SCRATCH_TEMPLATE',         __FILE__ );
  44.  
  45. /**
  46.  * Add Templates
  47.  * Note that values marked as "optional" must still be defined but left empty is not used.
  48.  * @since 1.0
  49.  * @version 1.0
  50.  */
  51. if ( ! function_exists( 'mycredpro_add_custom_scratch_template' ) ) :
  52.     function mycredpro_add_custom_scratch_template( $templates ) {
  53.  
  54.         $templates['my_template'] = array(
  55.             'label'               => 'My Template Name',
  56.             'minimum_scratch'     => 75,
  57.             'brush_diameter'      => 15,
  58.             'card_width'          => 300,
  59.             'card_height'         => 400,
  60.             'cover_image'         => plugins_url( 'templates/name/name-cover.png', CUSTOM_SCRATCH_TEMPLATE ),
  61.             'coin_image'          => '', // optional
  62.             'buy_log'             => '', // optional
  63.             'win_log'             => '', // optional
  64.             'win_message'         => '', // optional
  65.             'setup'               => array(
  66.                 array(
  67.                     'number'         => 100,
  68.                     'value'          => 0,
  69.                     'attachment_ids' => array(
  70.                         plugins_url( 'templates/name/name-nowin.png', CUSTOM_SCRATCH_TEMPLATE )
  71.                     )
  72.                 ),
  73.                 array(
  74.                     'number'         => 10,
  75.                     'value'          => 10,
  76.                     'attachment_ids' => array(
  77.                         plugins_url( 'templates/name/name-win.png', CUSTOM_SCRATCH_TEMPLATE )
  78.                     )
  79.                 )
  80.             )
  81.         );
  82.  
  83.         return $templates;
  84.  
  85.     }
  86. endif;
  87. add_filter( 'mycred_scratch_card_templates', 'mycredpro_add_custom_scratch_template' );
  88.  
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement