Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
adjust file format
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Fiebig committed Oct 7, 2016
1 parent f35bdf0 commit f92a9ec
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 26 deletions.
50 changes: 25 additions & 25 deletions composer.json
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"
}
}
79 changes: 78 additions & 1 deletion faf-compare.php
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');

0 comments on commit f92a9ec

Please sign in to comment.