Skip to content

Commit

Permalink
Added demo derived from origina favpress theme boilderplate.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Mörchen committed Oct 6, 2017
1 parent 45adefc commit 4013f10
Show file tree
Hide file tree
Showing 18 changed files with 3,062 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FavPress Demo Plugin
====================================

This plugins shows usage samples of FavPress (http://favpress.com).

It is a hard fork of the orignal Vafpress theme boilerplate (https://github.com/vafour/vafpress-framework-theme-boilerplate)
212 changes: 212 additions & 0 deletions admin/data_sources.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
<?php

FavPress_Security::instance()->whitelist_function('favpress_copy_content');

function favpress_copy_content($value, $value2) {
$args = func_get_args();
return implode('', $args);
}

FavPress_Security::instance()->whitelist_function('favpress_simple_shortcode');

function favpress_simple_shortcode($name = "", $url = "", $image = "") {
if (is_null($name)) $name = '';
if (is_null($url)) $url = '';
if (is_null($image)) $image = '';
$result = '[shortcode name="' . $name . '" url="' . $url . '" image="' . $image . '"]';
return $result;
}

FavPress_Security::instance()->whitelist_function('favpress_bind_bigcontinents');

function favpress_bind_bigcontinents() {
$bigcontinents = array(
'Eurafrasia',
'America',
'Oceania',
);

$result = array();

foreach ($bigcontinents as $data) {
$result[] = array('value' => $data, 'label' => $data, 'img' => 'http://placehold.it/100x100');
}

return $result;
}

FavPress_Security::instance()->whitelist_function('favpress_bind_continents');

function favpress_bind_continents($param = '') {
$continents = array(
'Eurafrasia' => array(
'Africa',
'Asia',
'Europe'
),
'America' => array(
'North America',
'Central America and the Antilles',
'South America'
),
'Oceania' => array(
'Australasia',
'Melanesia',
'Micronesia',
'Polynesia',
),
);

$result = array();
$datas = array();

if (is_array($param))
$param = reset($param);

if (array_key_exists($param, $continents))
$datas = $continents[$param];

foreach ($datas as $data) {
$result[] = array('value' => $data, 'label' => $data, 'img' => 'http://placehold.it/100x100');
}

return $result;
}

FavPress_Security::instance()->whitelist_function('favpress_bind_countries');

function favpress_bind_countries($param = '') {
$countries = array(
'Africa' => array(
'Algeria',
'Nigeria',
'Egypt',
),
'Asia' => array(
'Indonesia',
'Malaysia',
'China',
'Japan',
),
'Europe' => array(
'France',
'Germany',
'Italy',
'Netherlands',
),
'North America' => array(
'United States',
'Mexico',
'Canada',
),
'Central America and the Antilles' => array(
'Cuba',
'Guatemala',
'Haiti',
),
'South America' => array(
'Argentina',
'Brazil',
'Paraguay',
),
'Australasia' => array(
'Australia',
'New Zealand',
'Christmas Island',
),
'Melanesia' => array(
'Fiji',
'Papua New Guinea',
'Vanuatu',
),
'Micronesia' => array(
'Guam',
'Nauru',
'Palau'
),
'Polynesia' => array(
'American Samoa',
'Samoa',
'Tokelau',
),
);
$result = array();
$datas = array();

if (is_null($param))
$param = '';

if (is_array($param) and !empty($param))
$param = reset($param);

if (empty($param))
$param = '';

if (array_key_exists($param, $countries))
$datas = $countries[$param];

foreach ($datas as $data) {
$result[] = array('value' => $data, 'label' => $data, 'img' => 'http://placehold.it/100x100');
}

return $result;
}

FavPress_Security::instance()->whitelist_function('favpress_dep_is_keyword');

function favpress_dep_is_keyword($value) {
if ($value === 'keyword')
return true;
return false;
}

FavPress_Security::instance()->whitelist_function('favpress_dep_is_tags');

function favpress_dep_is_tags($value) {
if ($value === 'tags')
return true;
return false;
}

FavPress_Security::instance()->whitelist_function('favpress_bind_color_accent');

function favpress_bind_color_accent($preset) {
switch ($preset) {
case 'red':
return '#ff0000';
case 'green':
return '#00ff00';
case 'blue':
return '#0000ff';
default:
return '#000000';
}
}

FavPress_Security::instance()->whitelist_function('favpress_bind_color_subtle');

function favpress_bind_color_subtle($preset) {
return favpress_bind_color_accent($preset);
}

FavPress_Security::instance()->whitelist_function('favpress_bind_color_background');

function favpress_bind_color_background($preset) {
return favpress_bind_color_accent($preset);
}

FavPress_Security::instance()->whitelist_function('favpress_font_preview');

function favpress_font_preview($face, $style, $weight, $size, $line_height) {
$gwf = new FavPress_Site_GoogleWebFont();
$gwf->add($face, $style, $weight);
$links = $gwf->get_font_links();
$link = reset($links);
$dom = <<<EOD
<link href='$link' rel='stylesheet' type='text/css'>
<p style="padding: 0 10px 0 10px; font-family: $face; font-style: $style; font-weight: $weight; font-size: {$size}px; line-height: {$line_height}em;">
Grumpy wizards make toxic brew for the evil Queen and Jack
</p>
EOD;
return $dom;
}
78 changes: 78 additions & 0 deletions admin/metabox/sample_1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

return array(
'id' => 'favpress_meta_sample_1',
'types' => array('post'),
'title' => __('FavPress Dependent Fields and Group', 'favpress-demo-plugin'),
'priority' => 'high',
'template' => array(
array(
'type' => 'toggle',
'name' => 'toggle_filtering',
'label' => __('Use Filtering', 'favpress-demo-plugin'),
'description' => __('Checking this will show filtering option group.', 'favpress-demo-plugin'),
),
array(
'type' => 'group',
'repeating' => false,
'length' => 1,
'name' => 'filtering_group',
'title' => __('Filtering', 'favpress-demo-plugin'),
'dependency' => array(
'field' => 'toggle_filtering',
'function' => 'favpress_dep_boolean',
),
'fields' => array(
array(
'type' => 'radiobutton',
'name' => 'filter_type',
'label' => __('Filter By', 'favpress-demo-plugin'),
'description' => __('Different type will show different type of field', 'favpress-demo-plugin'),
'items' => array(
array(
'value' => 'keyword',
'label' => __('Keyword', 'favpress-demo-plugin'),
),
array(
'value' => 'tags',
'label' => __('Tags', 'favpress-demo-plugin'),
),
),
),
array(
'type' => 'textbox',
'name' => 'filter_keyword',
'label' => __('Keyword', 'favpress-demo-plugin'),
'description' => __('Keyword to filter.', 'favpress-demo-plugin'),
'default' => 'abcdefg',
'dependency' => array(
'field' => 'filter_type',
'function' => 'favpress_dep_is_keyword',
),
),
array(
'type' => 'multiselect',
'name' => 'filter_tags',
'label' => __('Choose Tag(s)', 'favpress-demo-plugin'),
'description' => __('Tag(s) to filter.', 'favpress-demo-plugin'),
'items' => array(
'data' => array(
array(
'source' => 'function',
'value' => 'favpress_get_tags',
),
),
),
'dependency' => array(
'field' => 'filter_type',
'function' => 'favpress_dep_is_tags',
),
),
),
),
),
);

/**
* EOF
*/
50 changes: 50 additions & 0 deletions admin/metabox/sample_2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

return array(
'id' => 'favpress_meta_sample_2',
'types' => array('post'),
'title' => __('FavPress Repeating Group With Binding Fields', 'favpress-demo-plugin'),
'priority' => 'high',
'template' => array(
array(
'type' => 'group',
'repeating' => true,
'name' => 'binding_group',
'title' => __('Reference', 'favpress-demo-plugin'),
'fields' => array(
array(
'type' => 'textbox',
'name' => 'name',
'label' => __('Name', 'favpress-demo-plugin'),
'description' => __('Source Name', 'favpress-demo-plugin'),
),
array(
'type' => 'textbox',
'name' => 'url',
'label' => __('URL', 'favpress-demo-plugin'),
'description' => __('Source URL', 'favpress-demo-plugin'),
),
array(
'type' => 'upload',
'name' => 'image',
'label' => __('Image', 'favpress-demo-plugin'),
'description' => __('Source Image', 'favpress-demo-plugin'),
),
array(
'type' => 'textbox',
'name' => 'shortcode',
'label' => __('Shortcode', 'favpress-demo-plugin'),
'description' => __('Shortcode', 'favpress-demo-plugin'),
'binding' => array(
'field' => 'name,url, image',
'function' => 'favpress_simple_shortcode'
)
),
),
),
),
);

/**
* EOF
*/
Loading

0 comments on commit 4013f10

Please sign in to comment.