Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author robert_kolatzek

    (@robert_kolatzek)

    Sorry for delay. (I never get mails from support forum and its make me crazy.)

    I will check if there are problems and where they are next days. Thanks for your message!

    Plugin Author robert_kolatzek

    (@robert_kolatzek)

    If I understood you right, you can not install this plugin because of the “highest tested version” which was set to 4.6. Functionally there was nothing to change. It works for me in two installations.
    1.0.8 should work!

    Thread Starter loretb

    (@loretb)

    Yeah that was the problem. I see that it should be compatible but when i download the latest and then try to install i get the following error: Parse error: syntax error, unexpected ‘[‘ in wpdoodlez/WPdoodlez.php on line 87

    i removed the home etc dir for security.

    Any ideas?

    Thread Starter loretb

    (@loretb)

    <?php
    /**
     * Plugin Name: WP doodlez
     * Plugin URI: https://github.com/Kolatzek/WPdoodlez
     * Description: Doodle like finding meeting date 
     * Author: Robert Kolatzek
     * Version: 1.0.8
     * Author URI: http://robert.kolatzek.org
     * License: GPL 2
     */
    
    /**
     * Translate string
     * @param string $text
     * @return string
     */
    function wpd_translate( $text ) {
        return __( $text, 'WPdoodlez' );
    }
    /**
     * Load plugin textdomain.
     */
    function WPdoodlez_load_textdomain() {
      load_plugin_textdomain( 'WPdoodlez', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' ); 
    }
    add_action( 'plugins_loaded', 'WPdoodlez_load_textdomain' );
    
    /**
     * Register own template for doodles
     * @global post $post
     * @param string $single_template
     * @return string
     */
    function wpdoodlez_template( $single_template ) {
        global $post;
        if ( $post->post_type == 'wpdoodle' ) {
            $single_template = dirname( __FILE__ ) . '/wpdoodle-template.php';
        }
        return $single_template;
    }
    
    add_filter( 'single_template', 'wpdoodlez_template' );
    
    /**
     * Save a single vote as ajax request and set cookie with given user name
     */
    function wpdoodlez_save_vote() {
        $values = get_option( 'wpdoodlez_' . strval($_POST[ 'data' ][ 'wpdoodle' ]), array() );
        $name   = sanitize_text_field( $_POST[ 'data' ][ 'name' ]);
        /* insert only without cookie (or empty name in cookie)
         * update only with same name in cookie
         */
        $nameInCookie = strval($_COOKIE[ 'wpdoodlez-' . $_POST[ 'data' ][ 'wpdoodle' ] ]);
        if ( (isset( $values[ $name ] ) && $nameInCookie == $name) ||
        (!isset( $values[ $name ] ) && empty( $nameInCookie ))
        ) {
            $values[ $name ] = array();
            foreach ( $_POST[ 'data' ][ 'vote' ] as $option ) {
                $values[ $name ][ strval($option[ 'name' ]) ] =  sanitize_text_field($option[ 'value' ]);
            }
        } else {
            echo json_encode( 
                array( 
                    'save' => false , 
                    'msg' => wpd_translate( 'You have already voted but your vote was deleted. Your name was: ' ).$nameInCookie ) 
            );
            wp_die();
        }
        update_option( 'wpdoodlez_' . (string)$_POST[ 'data' ][ 'wpdoodle' ], $values );
        setcookie( 'wpdoodlez-' . (string)$_POST[ 'data' ][ 'wpdoodle' ], $name, time() + (3600 * 24 * 30), COOKIEPATH, COOKIE_DOMAIN, is_ssl() );
        echo json_encode( array( 'save' => true ) );
        wp_die();
    }
    
    add_action( 'wp_ajax_wpdoodlez_save', 'wpdoodlez_save_vote' );
    add_action( 'wp_ajax_nopriv_wpdoodlez_save', 'wpdoodlez_save_vote' );
    
    /**
     * Delete a given vote identified by user name. Possible for all wp user with *delete_published_posts* right
     */
    function wpdoodlez_delete_vote() {
        if ( !current_user_can( 'delete_published_posts' ) ) {
            echo json_encode( array( 'delete' => false ) );
            wp_die();
        }
        $values    = get_option( 'wpdoodlez_' . (string)$_POST[ 'data' ][ 'wpdoodle' ], array() );
        $newvalues = [ ];
        foreach ( $values as $key => $value ) {
            if ( $key != (string) $_POST[ 'data' ][ 'name' ] ) {
                $newvalues[ $key ] = $value;
            }
        }
        update_option( 'wpdoodlez_' . (string)$_POST[ 'data' ][ 'wpdoodle' ], $newvalues );
        echo json_encode( array( 'delete' => true ) );
        wp_die();
    }
    
    add_action( 'wp_ajax_nopriv_wpdoodlez_delete', 'wpdoodlez_delete_vote' );
    add_action( 'wp_ajax_wpdoodlez_delete', 'wpdoodlez_delete_vote' );
    
    /**
     * Register WPdoodle post type
     * Set cookie with the name of user (used by voting)
     */
    function wpdoodlez_cookie() {
        include('wpdoodlez_post_type.php');
        foreach ( $_COOKIE as $key => $value ) {
            if ( preg_match( '/wpdoodlez\-.+/i', (string)$key ) ) {
                setcookie( (string)$key, (string)$value, time() + (3600 * 24 * 30), COOKIEPATH, COOKIE_DOMAIN, is_ssl() );
            }
        }
    }
    add_action( 'init', 'wpdoodlez_cookie' );
    
    /**
     * Register WPdoodle post type and refresh rewrite rules
     */
    function wpdoodlez_rewrite_flush() {
        wpdoodlez_cookie();
        flush_rewrite_rules();
    }
    
    register_activation_hook( __FILE__, 'wpdoodlez_rewrite_flush' );
    add_action( 'after_switch_theme', 'wpdoodlez_rewrite_flush' );
    ?>
    
    Plugin Author robert_kolatzek

    (@robert_kolatzek)

    $newvalues = [ ];

    right?

    Its a new version of “array()” known since PHP 5.6. You have a very old PHP version. It can be a security problem!

    Let me know if I’m right.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Latest wordpress’ is closed to new replies.