This repository has been archived by the owner on Mar 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Frank Fiebig
committed
Oct 7, 2016
1 parent
f35bdf0
commit f92a9ec
Showing
2 changed files
with
103 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
{ | ||
"name": "fafiebig/faf-compare", | ||
"description": "Wordpress Plugin for Image Compare based on TwentyTwenty.", | ||
"keywords": [ | ||
"wordpress", | ||
"plugin", | ||
"twentytwenty", | ||
"compare", | ||
"before", | ||
"after" | ||
], | ||
"homepage": "https://github.com/fafiebig/faf-compare", | ||
"license": "GNU GENERAL PUBLIC LICENSE", | ||
"authors": [ | ||
{ | ||
"name": "F.A. Fiebig", | ||
"email": "[email protected]", | ||
"homepage": "http://fafworx.de" | ||
} | ||
], | ||
"type": "wordpress-plugin", | ||
"require": { | ||
"php": ">=5.3.2", | ||
"composer/installers": "v1.2.0" | ||
} | ||
{ | ||
"name": "fafiebig/faf-compare", | ||
"description": "Wordpress Plugin for Image Compare based on TwentyTwenty.", | ||
"keywords": [ | ||
"wordpress", | ||
"plugin", | ||
"twentytwenty", | ||
"compare", | ||
"before", | ||
"after" | ||
], | ||
"homepage": "https://github.com/fafiebig/faf-compare", | ||
"license": "GNU GENERAL PUBLIC LICENSE", | ||
"authors": [ | ||
{ | ||
"name": "F.A. Fiebig", | ||
"email": "[email protected]", | ||
"homepage": "http://fafworx.de" | ||
} | ||
], | ||
"type": "wordpress-plugin", | ||
"require": { | ||
"php": ">=5.3.2", | ||
"composer/installers": "v1.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,78 @@ | ||
<?php/*Plugin Name: FAF ComparePlugin URI: https://github.com/fafiebig/faf-compareDescription: Show images before/after comparison of your WordPress images (based on TwentyTwenty).Version: 1.0Author: F.A. FiebigAuthor URI: http://fafworx.comLicense: GNU GENERAL PUBLIC LICENSE*/defined( 'ABSPATH' ) or die( 'No direct script access allowed!' );/** * load translation domain */function fafCompareLoadTextdomain(){ load_plugin_textdomain('faf-compare', false, dirname(plugin_basename(__FILE__)) . '/lang/');}add_action('plugins_loaded', 'fafCompareLoadTextdomain');/** * add scripts and styles */function fafCompareEnqueueScriptsStyles(){ wp_enqueue_script('tt-event-move-js', plugins_url('twentytwenty/js/jquery.event.move.js', __FILE__), array('jquery'), '1.0', true); wp_enqueue_script('tt-jquery-js', plugins_url('twentytwenty/js/jquery.twentytwenty.js', __FILE__), array('jquery'), '1.0', true); wp_enqueue_script('tt-compare-js', plugins_url('twentytwenty/js/jquery.compare.js', __FILE__), array('jquery'), '1.0', true); wp_enqueue_style('tt-foundation-css', plugins_url('twentytwenty/css/foundation.css', __FILE__)); wp_enqueue_style('tt-css', plugins_url('twentytwenty/css/twentytwenty.css', __FILE__), array('foundation-css'));}add_action('wp_enqueue_scripts', 'fafCompareEnqueueScriptsStyles');/** * add scripts and styles to admin */function fafCompareEnqueueAdminScriptsStyles(){ wp_enqueue_script('faf-compare-editor-js', plugins_url('editor/editor.js', __FILE__), array('jquery'), '1.0', true);}add_action('admin_enqueue_scripts', 'fafCompareEnqueueAdminScriptsStyles');/** * add editor button */function fafCompareAddEditorButton(){ echo '<a href="#" id="faf-compare-short" class="button">'.__('FAF Image Compare', 'faf-compare').'</a>';}add_action('media_buttons', 'fafCompareAddEditorButton', 101);/** * add short code * * @param $atts * @return string */function fafCompareShort( $atts ){ if (isset($atts['before']) && isset($atts['after'])) { $orientation = (isset($atts['orientation'])) ? $atts['orientation'] : 'horizontal'; $size = (isset($atts['size'])) ? $atts['size'] : 'thumbnail'; $before = $atts['before']; $after = $atts['after']; $html = '<div class="twentytwenty-container" data-orientation="'.$orientation.'">'; $html .= wp_get_attachment_image($before, $size); $html .= wp_get_attachment_image($after, $size); $html .= '</div>'; return $html; }}add_shortcode('compare', 'fafCompareShort'); | ||
<?php | ||
|
||
/* | ||
Plugin Name: FAF Compare | ||
Plugin URI: https://github.com/fafiebig/faf-compare | ||
Description: Show images before/after comparison of your WordPress images (based on TwentyTwenty). | ||
Version: 1.0 | ||
Author: F.A. Fiebig | ||
Author URI: http://fafworx.com | ||
License: GNU GENERAL PUBLIC LICENSE | ||
*/ | ||
|
||
defined( 'ABSPATH' ) or die( 'No direct script access allowed!' ); | ||
|
||
/** | ||
* load translation domain | ||
*/ | ||
function fafCompareLoadTextdomain() | ||
{ | ||
load_plugin_textdomain('faf-compare', false, dirname(plugin_basename(__FILE__)) . '/lang/'); | ||
} | ||
add_action('plugins_loaded', 'fafCompareLoadTextdomain'); | ||
|
||
/** | ||
* add scripts and styles | ||
*/ | ||
function fafCompareEnqueueScriptsStyles() | ||
{ | ||
wp_enqueue_script('tt-event-move-js', plugins_url('twentytwenty/js/jquery.event.move.js', __FILE__), array('jquery'), '1.0', true); | ||
wp_enqueue_script('tt-jquery-js', plugins_url('twentytwenty/js/jquery.twentytwenty.js', __FILE__), array('jquery'), '1.0', true); | ||
wp_enqueue_script('tt-compare-js', plugins_url('twentytwenty/js/jquery.compare.js', __FILE__), array('jquery'), '1.0', true); | ||
|
||
wp_enqueue_style('tt-foundation-css', plugins_url('twentytwenty/css/foundation.css', __FILE__)); | ||
wp_enqueue_style('tt-css', plugins_url('twentytwenty/css/twentytwenty.css', __FILE__), array('tt-foundation-css')); | ||
} | ||
add_action('wp_enqueue_scripts', 'fafCompareEnqueueScriptsStyles'); | ||
|
||
/** | ||
* add scripts and styles to admin | ||
*/ | ||
function fafCompareEnqueueAdminScriptsStyles() | ||
{ | ||
wp_enqueue_script('faf-compare-editor-js', plugins_url('editor/editor.js', __FILE__), array('jquery'), '1.0', true); | ||
} | ||
add_action('admin_enqueue_scripts', 'fafCompareEnqueueAdminScriptsStyles'); | ||
|
||
/** | ||
* add editor button | ||
*/ | ||
function fafCompareAddEditorButton() | ||
{ | ||
echo '<a href="#" id="faf-compare-short" class="button">'.__('FAF Image Compare', 'faf-compare').'</a>'; | ||
} | ||
add_action('media_buttons', 'fafCompareAddEditorButton', 101); | ||
|
||
/** | ||
* add short code | ||
* | ||
* @param $atts | ||
* @return string | ||
*/ | ||
function fafCompareShort( $atts ) | ||
{ | ||
if (isset($atts['before']) && isset($atts['after'])) { | ||
$orientation = (isset($atts['orientation'])) ? $atts['orientation'] : 'horizontal'; | ||
$size = (isset($atts['size'])) ? $atts['size'] : 'thumbnail'; | ||
$before = $atts['before']; | ||
$after = $atts['after']; | ||
|
||
$html = '<div class="twentytwenty-container" data-orientation="'.$orientation.'">'; | ||
$html .= wp_get_attachment_image($before, $size); | ||
$html .= wp_get_attachment_image($after, $size); | ||
$html .= '</div>'; | ||
|
||
return $html; | ||
} | ||
} | ||
add_shortcode('compare', 'fafCompareShort'); |