diff --git a/crop-thumbnails.php b/crop-thumbnails.php index e8c1067..2710f3d 100644 --- a/crop-thumbnails.php +++ b/crop-thumbnails.php @@ -1,12 +1,12 @@ . */ //cpt - stands for crop-post-thumbnail define('CROP_THUMBS_LANG','cpt_lang'); -define('CROP_THUMBS_VERSION','0.8.4'); +define('CROP_THUMBS_VERSION','0.10.0'); function cpt_plugin_init() { load_plugin_textdomain( CROP_THUMBS_LANG, false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' ); - - __('Crop your thumbnails, the easy way.');//have to be the same as the plugins-description - for automatic integration into poedit + + __('Crop your thumbnails, the easy way.');//have to be the same as the plugins-description - for automatic integration into poedit } add_action('plugins_loaded', 'cpt_plugin_init'); @@ -46,5 +46,6 @@ function cptGetWpVersion() { include_once(dirname(__FILE__).'/functions/settings.php'); include_once(dirname(__FILE__).'/functions/editor.php'); +include_once(dirname(__FILE__).'/functions/backendpreparer.php'); include_once(dirname(__FILE__).'/functions/save.php'); -?> \ No newline at end of file +?> diff --git a/css/cpt-window.css b/css/cpt-window.css index b5d16eb..53dabf7 100644 --- a/css/cpt-window.css +++ b/css/cpt-window.css @@ -16,6 +16,7 @@ .thumbnail-list li.active { background-color:#aad6f4; border:1px solid #aad6f4; } .thumbnail-list li span { display:block; font-size:0.8em; } .thumbnail-list li img { max-width:100%; height: auto; max-height:250px;} +.thumbnail-list li h3 { font-size:1em; } .thumbnail-list li .lowResWarning, .thumbnail-list li .badParameterWarning { font-style: italic; color:#990000;} diff --git a/css/options.css b/css/options.css index bd71b7f..6c2c600 100644 --- a/css/options.css +++ b/css/options.css @@ -1,2 +1,15 @@ .cpt_settings_paypal { border:1px solid #298CBA; border-radius:3px; background-color:#f6f6f6; max-width:30em; padding:0 0.5em; margin:2em 0; text-align:center; } -.cpt_settings_submit { margin-top:2em; } \ No newline at end of file +.cpt_settings_submit { margin-top:2em; } + +.cropThumbnailModal.ui-dialog { padding:0; border-radius: 0; border:0; } + +/*dialog headline*/ +.cropThumbnailModal.ui-dialog .ui-dialog-title { font-size:13px; font-family:'Open Sans', sans-serif; margin: 0; padding:0 29px 0 10px; line-height: 29px; } +.cropThumbnailModal.ui-dialog .ui-dialog-titlebar { padding:0; border:0; height: 29px; border-bottom:1px solid #DFDFDF; border-radius: 0; } +.cropThumbnailModal.ui-dialog .ui-button.ui-dialog-titlebar-close { width: 29px; height: 29px; margin: 0; } +.cropThumbnailModal.ui-dialog .ui-button.ui-dialog-titlebar-close:before { line-height: 29px; } +.cropThumbnailModal.ui-dialog .ui-dialog-titlebar-close span { display: none; } + +/*dialog content*/ +.cropThumbnailModal.ui-dialog .ui-dialog-content { padding:0; overflow: hidden; } +.cropThumbnailModal.ui-dialog .ui-dialog-content iframe { width:100%; height: 100%; } diff --git a/functions/backendpreparer.php b/functions/backendpreparer.php new file mode 100644 index 0000000..7bb6356 --- /dev/null +++ b/functions/backendpreparer.php @@ -0,0 +1,268 @@ + + +post_mime_type,$this->allowedMime)) { + $html = ''; + $html.= 'ID.',"viewmode":"single"}\' '; + $html.= 'title="'.esc_attr__('Crop Thumbnail',CROP_THUMBS_LANG).'">'; + $html.= ''.esc_html__('Crop Thumbnail',CROP_THUMBS_LANG); + $html.= ''; + + $form_fields['cropthumbnails'] = array( + 'label' => 'Crop Thumbnails',//no i18n cause it should be obvious what plugin is used here + 'input' => 'html', + 'html' => $html + ); + } + return $form_fields; + } +} +$cpt_postView = new CropPostThumbnailsBackendPreparer(); diff --git a/functions/editor.php b/functions/editor.php index 8fdd363..16eb7a4 100644 --- a/functions/editor.php +++ b/functions/editor.php @@ -1,20 +1,20 @@ byImageId(); } else { $failure_msg = '
'.__('No featured Image set for this post until now.',CROP_THUMBS_LANG).'
'; @@ -43,10 +43,10 @@ function ajaxWindow() { break; default: $failure_msg = __('An error happend!',CROP_THUMBS_LANG); - break; + break; } } - + if(!empty($failure_msg)) { $windowCssPath = apply_filters('crop_post_thumbnail_window_css', plugins_url('css/cpt-window.css',dirname(__FILE__))); wp_enqueue_style( 'cpt-window',$windowCssPath,array('wp-admin'),CROP_THUMBS_VERSION); @@ -55,7 +55,7 @@ function ajaxWindow() { } die();//to prevent to send back a "0" } - + /** * Display a list of images that are attached to this post_id. * Hightlight the post-thumbnail (if it is attached to this post_id) @@ -63,17 +63,17 @@ function ajaxWindow() { function listImages() { global $cptSettings; $options = $cptSettings->getOptions(); - + $data = $this->loadPostIdData(intval($_REQUEST['post_id'])); - + $parent_post_type = ''; $_tmp_post = get_post(intval($_REQUEST['post_id'])); if(!empty($_tmp_post)) { $parent_post_type = $_tmp_post->post_type; } - + $cptContent = ''; - + if($this->shouldBeHiddenOnPostType($options,$parent_post_type)) { $cptContent = '
'.__('Cropping is disabled for this post-type.',CROP_THUMBS_LANG).'
'; } elseif($data==false) { @@ -94,8 +94,8 @@ function listImages() {
@@ -109,7 +109,7 @@ function listImages() { getOptions(); $this->addDebug('options', print_r($options,true)); $image_obj = get_post(intval($_REQUEST['image_id'])); - + //$post_id_attached holds the id of the post the image is attached to - can be null/empty $post_id_attached = -1; if(!empty($image_obj->post_parent)) { - $post_id_attached=$image_obj->post_parent; + $post_id_attached=$image_obj->post_parent; } - + //$current_parent_post_type $current_parent_post_type = ''; $current_parent_post_id = -1; - + if(!empty($_REQUEST['parent_post_id'])) { $_tmp = get_post(intval($_REQUEST['parent_post_id'])); if(!empty($_tmp)) { - $current_parent_post_type = $_tmp->post_type; + $current_parent_post_type = $_tmp->post_type; $current_parent_post_id = $_tmp->ID; } } - + $all_image_sizes = $cptSettings->getImageSizes(); $this->addDebug('all_image_sizes', print_r($all_image_sizes,true)); - + $orig_img = wp_get_attachment_image_src($image_obj->ID, 'full'); $orig_img['gcd'] = $this->gcd($orig_img[1],$orig_img[2]); $orig_img['ratio'] = ($orig_img[1]/$orig_img['gcd']) / ($orig_img[2]/$orig_img['gcd']); $orig_img['print_ratio'] = ($orig_img[1]/$orig_img['gcd']).':'.($orig_img[2]/$orig_img['gcd']); - + $cache_breaker = time();//a additional parameter that will be added to the image-urls to prevent the browser to show a cached image - + $this->addDebug('img-postmeta',print_r(wp_get_attachment_metadata($image_obj->ID, true),true)); - + //the javascript ob_start(); ?> - \ No newline at end of file diff --git a/functions/settings.php b/functions/settings.php index b10e6b5..282e111 100644 --- a/functions/settings.php +++ b/functions/settings.php @@ -4,7 +4,7 @@ class CropThumbnailsSettings { private $optionsKey = 'crop-post-thumbs'; private $cssPrefix = 'cpt_settings_'; private $standardSizes = array('thumbnail','medium','large'); - + function __construct() { add_action('admin_menu', array($this,'addOptionsPage')); if(is_admin()) { @@ -12,26 +12,26 @@ function __construct() { add_action('admin_head', array($this,'optionsPageStyle')); } } - + function optionsPageStyle() { if(!empty($_REQUEST['page']) && $_REQUEST['page']=='page-cpt') { wp_enqueue_style('crop-thumbnails-options-style',plugins_url('css/options.css',dirname(__FILE__))); } } - + function addSettingsLinkToPluginPage($links, $file) { - if ($file === 'crop-thumbnails/crop-thumbnails.php'){ - $settings_link = ''.__('Settings',CROP_THUMBS_LANG).''; - array_unshift( $links, $settings_link ); - } - return $links; + if ($file === 'crop-thumbnails/crop-thumbnails.php'){ + $settings_link = ''.__('Settings',CROP_THUMBS_LANG).''; + array_unshift( $links, $settings_link ); + } + return $links; } - + function addOptionsPage() { add_options_page(__('Crop Post Thumbnail Page',CROP_THUMBS_LANG), 'Crop-Thumbnails', 'manage_options', 'page-cpt', array($this,'optionsPage')); add_action('admin_init', array($this,'settingsInitialisation')); } - + function optionsPage() { ?>

@@ -39,12 +39,12 @@ function optionsPage() { ?>
uniqeSettingsId); ?> - +
-
+
- +

(and let him know you love this plugin)
by donating via Paypal. Thanks a lot!',CROP_THUMBS_LANG); ?>

@@ -64,10 +64,10 @@ function optionsPage() { ?>
uniqeSettingsId, $this->optionsKey, array($this,'validateSettings') ); - + $_sectionID = 'choose_sizes_section'; add_settings_section($_sectionID, __('Sizes and Posttypes',CROP_THUMBS_LANG), array($this,'sectionDescriptionChooseSizes'), 'page1'); add_settings_field('sizes', __('Choose the image-sizes you want to hide. Choose a post-type to prevent any use of the plugin for these entries.',CROP_THUMBS_LANG), array($this,'callback_choose_size'), 'page1', $_sectionID); @@ -84,7 +84,7 @@ function settingsInitialisation(){ $_tmpID = 'debug_data'; add_settings_field($_tmpID, __('Enable Data-Debug.',CROP_THUMBS_LANG), array($this,'callback_'.$_tmpID), 'page1', $_sectionID, array( 'label_for' => $this->cssPrefix.$_tmpID )); } - + function sectionDescriptionChooseSizes() {?>

@@ -92,7 +92,7 @@ function sectionDescriptionChooseSizes() {?>

'.print_r($options,true).''; $post_types = $this->getPostTypes(); $image_sizes = $this->getImageSizes(); - + //output echo '