Plugin Directory

Changeset 2449354


Ignore:
Timestamp:
01/03/2021 10:07:21 AM (5 years ago)
Author:
yoannspace
Message:

Release 1.2.0

Location:
display-your-zenodo-community
Files:
8 edited
14 copied

Legend:

Unmodified
Added
Removed
  • display-your-zenodo-community/tags/1.2.0/CHANGELOG.md

    r2333508 r2449354  
    55and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
    66
    7 ## [Unreleased]
     7## [1.2.0] - 2021-01-03
     8### Added
     9- Administrators can add a keyword for limiting the results. This is for example to select a subset of the publication for a certain project within an institution.
     10- Administrators can choose the number of publications shown per page (default is 10)
     11### Changed
     12* Fixed a bug that would make the plugin query Zenodo at the init stage of all pages
    813
    914## [1.1.0] - 2020-07-01
  • display-your-zenodo-community/tags/1.2.0/README.md

    r2333508 r2449354  
    1717
    1818A very simple administration page (in Settings -> Zenodo) to choose your Zenodo community (e.g. `dariah` or `operaseu
    19 `) or choose your personal ORCID.
     19`) or choose your personal ORCID. For administrators, possibility as well to search for a subset (with keywords) of
     20 the publications, as well as possibility to choose the number of publication shown per page.
    2021On the page you want to present the Zenodo data, add the shortcode `[display-your-zenodo-community]` to see the publications.
    2122# How does it work?
  • display-your-zenodo-community/tags/1.2.0/README.txt

    r2439787 r2449354  
    66Tested up to: 5.6
    77Requires PHP: 5.6.35
    8 Stable tag: 1.1.0
     8Stable tag: 1.2.0
    99License: Apache License - 2.0
    1010License URI: http://www.apache.org/licenses/LICENSE-2.0
     
    2929
    3030A very simple administration page (in Settings -> Zenodo) to choose your Zenodo community (e.g. `dariah` or `operaseu`).
     31For administrators, possibility as well to search for a subset (with keywords) of the publications, as well as possibility to choose the number of publication shown per page.
    3132On the page you want to present the Zenodo data, add the shortcode `[display-your-zenodo-community]` to see the publications.
    3233
     
    4445
    4546== Changelog ==
     47
     48= 1.2.0 =
     49* Administrators can add a keyword for limiting the results. This is for example to select a subset of the publication for a certain project within an institution.
     50* Administrators can choose the number of publications shown per page (default is 10)
     51* Fixed a bug that would make the plugin query Zenodo at the init stage of all pages
    4652
    4753= 1.1.0 =
  • display-your-zenodo-community/tags/1.2.0/admin/class-display-your-zenodo-community-admin.php

    r2333508 r2449354  
    127127     */
    128128    public function options_update() {
    129         register_setting( $this->plugin_name, $this->plugin_name, array( 'sanitize_callback' => array( $this, 'validate' ), 'default' => array( 'id_community_orcid' => '', 'choice' => '' ) ) );
     129        register_setting( $this->plugin_name, $this->plugin_name, array( 'sanitize_callback' => array( $this, 'validate' ), 'default' => array( 'id_community_orcid' => '', 'choice' => '', 'extra_keyword' => '', 'number_publications' => 10 ) ) );
    130130    }
    131131    /**
     
    140140            sanitize_text_field($input['id_community_orcid']) : '';
    141141        $valid['choice'] = sanitize_text_field($input['choice']);
     142        $valid['extra_keyword'] = (isset($input['extra_keyword']) && !empty($input['extra_keyword'])) ?
     143            sanitize_text_field($input['extra_keyword']) : '';
     144        $valid['number_publications'] = (isset($input['number_publications']) && !empty($input['number_publications'])) ?
     145            sanitize_text_field($input['number_publications']) : 10;
    142146        return $valid;
    143147    }
  • display-your-zenodo-community/tags/1.2.0/admin/partials/display-your-zenodo-community-admin-display.php

    r2333508 r2449354  
    3232        //Grab all options
    3333        $display_your_zenodo_community_options = get_option( $this->plugin_name );
    34         $choice = $display_your_zenodo_community_options['choice'];
    35         $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
     34        $choice = $id_community_orcid = $extra_keyword = "";
     35        $number_publications = 10;
     36        if( array_key_exists( 'choice', $display_your_zenodo_community_options ) ) {
     37            $choice = $display_your_zenodo_community_options['choice'];
     38        }
     39        if( array_key_exists( 'id_community_orcid', $display_your_zenodo_community_options ) ) {
     40            $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
     41        }
     42        if( array_key_exists( 'extra_keyword', $display_your_zenodo_community_options ) ) {
     43            $extra_keyword = $display_your_zenodo_community_options['extra_keyword'];
     44        }
     45        if( array_key_exists( 'number_publications', $display_your_zenodo_community_options ) ) {
     46            $number_publications = $display_your_zenodo_community_options['number_publications'];
     47        }
    3648
    3749        $html = "<tr>
     
    5769                    </td>
    5870                </tr>";
     71        $html .= "<tr>
     72                    <th scope=\"row\">
     73                        <label for=\"" . $this->plugin_name . "-extra-keyword\">" . translate('Refine search with keywords (tags in Zenodo e.g. TRIPLE)',
     74                $this->plugin_name) . "</label>
     75                    </th>
     76                    <td>
     77                        <input name=\"" . $this->plugin_name . "[extra_keyword]\" id=\"" . $this->plugin_name
     78            . "-extra-keyword\" value=\"" . $extra_keyword . "\" type=\"text\">
     79                    </td>
     80                </tr>";
     81        $html .= "<tr>
     82                    <th scope=\"row\">
     83                        <label for=\"" . $this->plugin_name . "-number-publications\">" . translate('Number of publications shown per page (default in Zenodo is 10)',
     84                $this->plugin_name) . "</label>
     85                    </th>
     86                    <td>
     87                        <input name=\"" . $this->plugin_name . "[number_publications]\" id=\"" . $this->plugin_name
     88            . "-number-publications\" value=\"" . $number_publications . "\" type=\"number\" min=\"1\" max=\"100\">
     89                    </td>
     90                </tr>";
    5991
    6092        settings_fields( $this->plugin_name );
  • display-your-zenodo-community/tags/1.2.0/includes/class-display-your-zenodo-community.php

    r2333508 r2449354  
    5454            $this->version = ZENODO_PLUGIN_VERSION;
    5555        } else {
    56             $this->version = '1.1.0';
     56            $this->version = '1.2.0';
    5757        }
    5858        $this->plugin_name = 'display-your-zenodo-community';
     
    143143        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
    144144
    145         $this->loader->add_filter( 'init', $plugin_public, 'zp_retrieve_json' );
    146145        $this->loader->add_filter( 'query_vars', $plugin_public, 'zp_query_vars' );
    147146    }
  • display-your-zenodo-community/tags/1.2.0/public/class-display-your-zenodo-community-public.php

    r2333508 r2449354  
    9696     */
    9797    public function display_zenodo_data() {
    98         $display_your_zenodo_community_options = get_option( $this->plugin_name );
    99         $choice = $display_your_zenodo_community_options['choice'];
    100         $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
     98        $display_your_zenodo_community_options = get_option( $this->plugin_name );
     99        $number_publications = 10;
     100        if( array_key_exists( 'number_publications', $display_your_zenodo_community_options ) ) {
     101            $number_publications = $display_your_zenodo_community_options['number_publications'];
     102        }
    101103
    102104        $page = 1;
     
    105107        }
    106108        $html = "<div id=\"display-your-zenodo-community\">";
    107         $result_api = $this->zp_retrieve_json( $page );
     109        $result_api = $this->zp_retrieve_json( $page, $display_your_zenodo_community_options );
    108110        $nb_pages = 1;
    109111        if( isset( $result_api->aggregations->access_right->buckets[0]->doc_count ) ) {
    110             $nb_pages = ceil( $result_api->aggregations->access_right->buckets[0]->doc_count / 10 );
     112            $nb_pages = ceil( $result_api->aggregations->access_right->buckets[0]->doc_count / $number_publications );
    111113            $html .= "<hr>";
    112114            $html .= "<div class=\"counter-doc\">";
    113115            $html .= "<span class=\"wphal-nbtot\">";
    114116            $html .= $result_api->aggregations->access_right->buckets[0]->doc_count;
    115             $html .= "</span>" . " documents (from " . ($choice=='community'?"Community \"":"ORCID \"") .
    116                      $id_community_orcid . "\")";
     117            $html .= "</span>" . " documents";
    117118            $html .= "</div>";
    118119        }
     
    218219     * @since    1.0.0
    219220     */
    220     public function zp_retrieve_json( $page = 1 ) {
    221         $display_your_zenodo_community_options = get_option( $this->plugin_name );
    222         $choice = $display_your_zenodo_community_options['choice'];
    223         $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
    224 
    225         $zenodo_api_url = "";
     221    public function zp_retrieve_json( $page = 1, $display_your_zenodo_community_options ) {
     222        $choice = $id_community_orcid = $extra_keyword = "";
     223        $number_publications = 10;
     224        if( array_key_exists( 'choice', $display_your_zenodo_community_options ) ) {
     225            $choice = $display_your_zenodo_community_options['choice'];
     226        }
     227        if( array_key_exists( 'id_community_orcid', $display_your_zenodo_community_options ) ) {
     228            $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
     229        }
     230        if( array_key_exists( 'extra_keyword', $display_your_zenodo_community_options ) ) {
     231            $extra_keyword = $display_your_zenodo_community_options['extra_keyword'];
     232        }
     233        if( array_key_exists( 'number_publications', $display_your_zenodo_community_options ) ) {
     234            $number_publications = $display_your_zenodo_community_options['number_publications'];
     235        }
     236
     237        $zenodo_api_url = "https://zenodo.org/api/records/?sort=mostrecent&size=" .$number_publications . "&page=" . $page . "&";
     238        $zenodo_api_query = "";
    226239        if( $choice == 'community' ) {
    227             $zenodo_api_url = "https://zenodo.org/api/records/?sort=mostrecent&size=10&communities=" . $id_community_orcid;
    228             $zenodo_api_url .= "&page=" . $page;
     240            $zenodo_api_query = "communities=" . $id_community_orcid;
     241            if( $extra_keyword !== '' ) {
     242                $zenodo_api_query .= "&q=keywords:%22" . $extra_keyword . "%22";
     243            }
    229244        } elseif ( $choice == 'orcid' ) {
    230             $zenodo_api_url = "https://zenodo.org/api/records/?q=creators.orcid:%22" . $id_community_orcid . "%22";
    231             $zenodo_api_url .= "&page=" . $page;
    232         }
     245            $zenodo_api_query = "q=(creators.orcid:%22" . $id_community_orcid . "%22";
     246            if( $extra_keyword !== '' ) {
     247                $zenodo_api_query .= " AND keywords:%22" . $extra_keyword . "%22)";
     248            } else {
     249                $zenodo_api_query .= ")";
     250            }
     251        }
     252        $zenodo_api_url .= $zenodo_api_query;
    233253        if( $id_community_orcid !== '' && $zenodo_api_url !== '' ) {
    234254            $request = wp_remote_get( $zenodo_api_url );
  • display-your-zenodo-community/tags/1.2.0/zenodo-plugin.php

    r2333508 r2449354  
    1717 * Plugin URI:        https://github.com/dariah-eric/display-your-zenodo-community
    1818 * Description:       This plugin allows user to view their community data from Zenodo on WordPress
    19  * Version:           1.1.0
     19 * Version:           1.2.0
    2020 * Author:            DARIAH-EU
    2121 * Author URI:        https://www.dariah.eu
  • display-your-zenodo-community/trunk/CHANGELOG.md

    r2333508 r2449354  
    55and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
    66
    7 ## [Unreleased]
     7## [1.2.0] - 2021-01-03
     8### Added
     9- Administrators can add a keyword for limiting the results. This is for example to select a subset of the publication for a certain project within an institution.
     10- Administrators can choose the number of publications shown per page (default is 10)
     11### Changed
     12* Fixed a bug that would make the plugin query Zenodo at the init stage of all pages
    813
    914## [1.1.0] - 2020-07-01
  • display-your-zenodo-community/trunk/README.md

    r2333508 r2449354  
    1717
    1818A very simple administration page (in Settings -> Zenodo) to choose your Zenodo community (e.g. `dariah` or `operaseu
    19 `) or choose your personal ORCID.
     19`) or choose your personal ORCID. For administrators, possibility as well to search for a subset (with keywords) of
     20 the publications, as well as possibility to choose the number of publication shown per page.
    2021On the page you want to present the Zenodo data, add the shortcode `[display-your-zenodo-community]` to see the publications.
    2122# How does it work?
  • display-your-zenodo-community/trunk/README.txt

    r2439787 r2449354  
    66Tested up to: 5.6
    77Requires PHP: 5.6.35
    8 Stable tag: 1.1.0
     8Stable tag: 1.2.0
    99License: Apache License - 2.0
    1010License URI: http://www.apache.org/licenses/LICENSE-2.0
     
    2929
    3030A very simple administration page (in Settings -> Zenodo) to choose your Zenodo community (e.g. `dariah` or `operaseu`).
     31For administrators, possibility as well to search for a subset (with keywords) of the publications, as well as possibility to choose the number of publication shown per page.
    3132On the page you want to present the Zenodo data, add the shortcode `[display-your-zenodo-community]` to see the publications.
    3233
     
    4445
    4546== Changelog ==
     47
     48= 1.2.0 =
     49* Administrators can add a keyword for limiting the results. This is for example to select a subset of the publication for a certain project within an institution.
     50* Administrators can choose the number of publications shown per page (default is 10)
     51* Fixed a bug that would make the plugin query Zenodo at the init stage of all pages
    4652
    4753= 1.1.0 =
  • display-your-zenodo-community/trunk/admin/class-display-your-zenodo-community-admin.php

    r2333508 r2449354  
    127127     */
    128128    public function options_update() {
    129         register_setting( $this->plugin_name, $this->plugin_name, array( 'sanitize_callback' => array( $this, 'validate' ), 'default' => array( 'id_community_orcid' => '', 'choice' => '' ) ) );
     129        register_setting( $this->plugin_name, $this->plugin_name, array( 'sanitize_callback' => array( $this, 'validate' ), 'default' => array( 'id_community_orcid' => '', 'choice' => '', 'extra_keyword' => '', 'number_publications' => 10 ) ) );
    130130    }
    131131    /**
     
    140140            sanitize_text_field($input['id_community_orcid']) : '';
    141141        $valid['choice'] = sanitize_text_field($input['choice']);
     142        $valid['extra_keyword'] = (isset($input['extra_keyword']) && !empty($input['extra_keyword'])) ?
     143            sanitize_text_field($input['extra_keyword']) : '';
     144        $valid['number_publications'] = (isset($input['number_publications']) && !empty($input['number_publications'])) ?
     145            sanitize_text_field($input['number_publications']) : 10;
    142146        return $valid;
    143147    }
  • display-your-zenodo-community/trunk/admin/partials/display-your-zenodo-community-admin-display.php

    r2333508 r2449354  
    3232        //Grab all options
    3333        $display_your_zenodo_community_options = get_option( $this->plugin_name );
    34         $choice = $display_your_zenodo_community_options['choice'];
    35         $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
     34        $choice = $id_community_orcid = $extra_keyword = "";
     35        $number_publications = 10;
     36        if( array_key_exists( 'choice', $display_your_zenodo_community_options ) ) {
     37            $choice = $display_your_zenodo_community_options['choice'];
     38        }
     39        if( array_key_exists( 'id_community_orcid', $display_your_zenodo_community_options ) ) {
     40            $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
     41        }
     42        if( array_key_exists( 'extra_keyword', $display_your_zenodo_community_options ) ) {
     43            $extra_keyword = $display_your_zenodo_community_options['extra_keyword'];
     44        }
     45        if( array_key_exists( 'number_publications', $display_your_zenodo_community_options ) ) {
     46            $number_publications = $display_your_zenodo_community_options['number_publications'];
     47        }
    3648
    3749        $html = "<tr>
     
    5769                    </td>
    5870                </tr>";
     71        $html .= "<tr>
     72                    <th scope=\"row\">
     73                        <label for=\"" . $this->plugin_name . "-extra-keyword\">" . translate('Refine search with keywords (tags in Zenodo e.g. TRIPLE)',
     74                $this->plugin_name) . "</label>
     75                    </th>
     76                    <td>
     77                        <input name=\"" . $this->plugin_name . "[extra_keyword]\" id=\"" . $this->plugin_name
     78            . "-extra-keyword\" value=\"" . $extra_keyword . "\" type=\"text\">
     79                    </td>
     80                </tr>";
     81        $html .= "<tr>
     82                    <th scope=\"row\">
     83                        <label for=\"" . $this->plugin_name . "-number-publications\">" . translate('Number of publications shown per page (default in Zenodo is 10)',
     84                $this->plugin_name) . "</label>
     85                    </th>
     86                    <td>
     87                        <input name=\"" . $this->plugin_name . "[number_publications]\" id=\"" . $this->plugin_name
     88            . "-number-publications\" value=\"" . $number_publications . "\" type=\"number\" min=\"1\" max=\"100\">
     89                    </td>
     90                </tr>";
    5991
    6092        settings_fields( $this->plugin_name );
  • display-your-zenodo-community/trunk/includes/class-display-your-zenodo-community.php

    r2333508 r2449354  
    5454            $this->version = ZENODO_PLUGIN_VERSION;
    5555        } else {
    56             $this->version = '1.1.0';
     56            $this->version = '1.2.0';
    5757        }
    5858        $this->plugin_name = 'display-your-zenodo-community';
     
    143143        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
    144144
    145         $this->loader->add_filter( 'init', $plugin_public, 'zp_retrieve_json' );
    146145        $this->loader->add_filter( 'query_vars', $plugin_public, 'zp_query_vars' );
    147146    }
  • display-your-zenodo-community/trunk/public/class-display-your-zenodo-community-public.php

    r2333508 r2449354  
    9696     */
    9797    public function display_zenodo_data() {
    98         $display_your_zenodo_community_options = get_option( $this->plugin_name );
    99         $choice = $display_your_zenodo_community_options['choice'];
    100         $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
     98        $display_your_zenodo_community_options = get_option( $this->plugin_name );
     99        $number_publications = 10;
     100        if( array_key_exists( 'number_publications', $display_your_zenodo_community_options ) ) {
     101            $number_publications = $display_your_zenodo_community_options['number_publications'];
     102        }
    101103
    102104        $page = 1;
     
    105107        }
    106108        $html = "<div id=\"display-your-zenodo-community\">";
    107         $result_api = $this->zp_retrieve_json( $page );
     109        $result_api = $this->zp_retrieve_json( $page, $display_your_zenodo_community_options );
    108110        $nb_pages = 1;
    109111        if( isset( $result_api->aggregations->access_right->buckets[0]->doc_count ) ) {
    110             $nb_pages = ceil( $result_api->aggregations->access_right->buckets[0]->doc_count / 10 );
     112            $nb_pages = ceil( $result_api->aggregations->access_right->buckets[0]->doc_count / $number_publications );
    111113            $html .= "<hr>";
    112114            $html .= "<div class=\"counter-doc\">";
    113115            $html .= "<span class=\"wphal-nbtot\">";
    114116            $html .= $result_api->aggregations->access_right->buckets[0]->doc_count;
    115             $html .= "</span>" . " documents (from " . ($choice=='community'?"Community \"":"ORCID \"") .
    116                      $id_community_orcid . "\")";
     117            $html .= "</span>" . " documents";
    117118            $html .= "</div>";
    118119        }
     
    218219     * @since    1.0.0
    219220     */
    220     public function zp_retrieve_json( $page = 1 ) {
    221         $display_your_zenodo_community_options = get_option( $this->plugin_name );
    222         $choice = $display_your_zenodo_community_options['choice'];
    223         $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
    224 
    225         $zenodo_api_url = "";
     221    public function zp_retrieve_json( $page = 1, $display_your_zenodo_community_options ) {
     222        $choice = $id_community_orcid = $extra_keyword = "";
     223        $number_publications = 10;
     224        if( array_key_exists( 'choice', $display_your_zenodo_community_options ) ) {
     225            $choice = $display_your_zenodo_community_options['choice'];
     226        }
     227        if( array_key_exists( 'id_community_orcid', $display_your_zenodo_community_options ) ) {
     228            $id_community_orcid = $display_your_zenodo_community_options['id_community_orcid'];
     229        }
     230        if( array_key_exists( 'extra_keyword', $display_your_zenodo_community_options ) ) {
     231            $extra_keyword = $display_your_zenodo_community_options['extra_keyword'];
     232        }
     233        if( array_key_exists( 'number_publications', $display_your_zenodo_community_options ) ) {
     234            $number_publications = $display_your_zenodo_community_options['number_publications'];
     235        }
     236
     237        $zenodo_api_url = "https://zenodo.org/api/records/?sort=mostrecent&size=" .$number_publications . "&page=" . $page . "&";
     238        $zenodo_api_query = "";
    226239        if( $choice == 'community' ) {
    227             $zenodo_api_url = "https://zenodo.org/api/records/?sort=mostrecent&size=10&communities=" . $id_community_orcid;
    228             $zenodo_api_url .= "&page=" . $page;
     240            $zenodo_api_query = "communities=" . $id_community_orcid;
     241            if( $extra_keyword !== '' ) {
     242                $zenodo_api_query .= "&q=keywords:%22" . $extra_keyword . "%22";
     243            }
    229244        } elseif ( $choice == 'orcid' ) {
    230             $zenodo_api_url = "https://zenodo.org/api/records/?q=creators.orcid:%22" . $id_community_orcid . "%22";
    231             $zenodo_api_url .= "&page=" . $page;
    232         }
     245            $zenodo_api_query = "q=(creators.orcid:%22" . $id_community_orcid . "%22";
     246            if( $extra_keyword !== '' ) {
     247                $zenodo_api_query .= " AND keywords:%22" . $extra_keyword . "%22)";
     248            } else {
     249                $zenodo_api_query .= ")";
     250            }
     251        }
     252        $zenodo_api_url .= $zenodo_api_query;
    233253        if( $id_community_orcid !== '' && $zenodo_api_url !== '' ) {
    234254            $request = wp_remote_get( $zenodo_api_url );
  • display-your-zenodo-community/trunk/zenodo-plugin.php

    r2333508 r2449354  
    1717 * Plugin URI:        https://github.com/dariah-eric/display-your-zenodo-community
    1818 * Description:       This plugin allows user to view their community data from Zenodo on WordPress
    19  * Version:           1.1.0
     19 * Version:           1.2.0
    2020 * Author:            DARIAH-EU
    2121 * Author URI:        https://www.dariah.eu
Note: See TracChangeset for help on using the changeset viewer.