Plugin Directory

Changeset 412200


Ignore:
Timestamp:
07/19/2011 09:10:54 PM (15 years ago)
Author:
jaredh123
Message:

update img protection js for WordPress 3.2+

File:
1 edited

Legend:

Unmodified
Added
Removed
  • prophoto2-compatibility-patches/trunk/p2-wp-compatibility.php

    r248279 r412200  
    55Description: Only for users of version 2 of the ProPhoto theme. Contains patches required for compatibility with WordPress 3.0+
    66Author: ProPhotoBlogs
    7 Version: 1.0
     7Version: 1.1
    88*/
    99
    1010
     11add_action( 'wp_loaded', 'p2_update_img_protection_opts' );
     12add_action( 'wp_loaded', 'p2_update_img_protection_js' );
     13
     14
     15function p2_update_img_protection_opts() {
     16    global $p2;
     17    $storeNew = false;
     18
     19
     20    if ( p2_test( 'no_right_click', ' ondragstart="return false" onselectstart="return false"') ) {
     21        $p2['options']['settings']['no_right_click'] = ' ondragstart="return false" onselectstart="return false" id="wp-pp"';
     22        $p2['options']['settings']['updated_no_right_click'] = 'true';
     23        $storeNew = true;
     24    }
     25   
     26    if ( p2_test( 'no_left_click', 'on' ) ) {
     27        $p2['options']['settings']['no_left_click'] = 'off';
     28        $p2['options']['settings']['updated_no_left_click'] = 'true';
     29        $storeNew = true;
     30    }
     31   
     32    if ( $storeNew ) {
     33        p2_store_options();
     34    }
     35}
     36
     37function p2_update_img_protection_js() {
     38    $newJS = null;
     39   
     40    if ( p2_test( 'updated_no_right_click', 'true' ) ) {
     41        $newJS = "jQuery('.alignnone, .aligncenter, .alignright, .alignleft, .gallery img, a[href$=\".jpg\"], a[href$=\".gif\"], a[href$=\".png\"], a[href$=\".JPG\"], a[href$=\".GIF\"], a[href$=\".PNG\"]')";
     42    }
     43   
     44    if ( $newJS && p2_test( 'updated_no_left_click', 'true' ) ) {
     45        $newJS .= ".css('cursor', 'default').click(function(){return false;})";
     46    }
     47   
     48    if ( $newJS ) {
     49        $newJS .= ".bind('contextmenu', function(){return false;});";
     50    }
     51   
     52    if ( $newJS ) {
     53        $newJS = addslashes( 'jQuery(document).ready(function($){ ' . $newJS . ' });' );
     54        add_action( 'wp_head', create_function( '', "echo '<script> $newJS </script>';" ) );
     55    }
     56}
     57
    1158
    1259if ( !function_exists( 'p2_insert_upload_fields' ) ) {
    13    
     60
     61
    1462    /* get custom P2 fields inside of upload form */
    1563    function p2_insert_upload_fields() {
     
    4997
    5098    /* add actions */
    51     if ( get_option( 'template' ) == 'prophoto2' ) {
     99    if ( get_option( 'template' ) == 'prophoto2' ) {       
    52100        if ( !is_admin() ) add_action( 'wp_head', 'p2_compat_doctor_mark' );
    53101        if ( $pagenow == 'popup.php' ) add_action( 'pre-upload-ui', 'p2_insert_upload_fields' );
     
    62110
    63111
    64 ?>
Note: See TracChangeset for help on using the changeset viewer.