Plugin Directory

Changeset 2713005


Ignore:
Timestamp:
04/21/2022 08:55:55 PM (4 years ago)
Author:
wordable
Message:

8.0.5

Location:
wordable
Files:
1 added
12 edited
4 copied

Legend:

Unmodified
Added
Removed
  • wordable/tags/8.0.5/includes/action_params.php

    r2701468 r2713005  
    5757      $author_id = intval($this->params['post']['author_id']);
    5858
    59       if(!$this->user_exists($author_id)) {
     59      if(!$this->author_exists($author_id)) {
    6060        $this->params['post']['author_id'] = null;
    6161      } else {
     
    8181
    8282  // Helpers
    83   function user_exists($user_id) {
    84     foreach($this->wordable_plugin_actions->users() as $user) {
    85       if($user->ID == $user_id) {
     83  function author_exists($author_id) {
     84    foreach($this->wordable_plugin_actions->authors() as $author) {
     85      if($author->ID == $author_id) {
    8686        return true;
    8787      }
  • wordable/tags/8.0.5/includes/actions.php

    r2701468 r2713005  
    4545  function action() {
    4646    $params = $this->parse_and_validate_params();
    47 
    48     if($params['post'] && $params['post']['author_id']) {
    49       wp_set_current_user($params['post']['author_id']);
    50     } else if (count($this->users()) > 0) {
    51       wp_set_current_user(array_values($this->users())[0]->ID);
    52     }
    5347
    5448    return $this->{$params['method'].'_action'}($params);
     
    106100
    107101  function create_post_action($params) {
     102    if($params['post'] && $params['post']['author_id']) {
     103      wp_set_current_user($params['post']['author_id']);
     104    } else {
     105      $current_user_id = $this->user_id_to_be_current();
     106
     107      if($current_user_id) {
     108        wp_set_current_user($current_user_id);
     109      }
     110    }
     111
    108112    $post_attributes = array(
    109113      'post_author' => $params['post']['author_id'],
     
    117121
    118122    $post_id = $this->throw_if_wp_error(wp_insert_post($post_attributes, true));
    119     return $this->segmented_post_hook($post_id, $post_attributes);
     123    return $this->segmented_post_hook($post_id, $post_attributes, $params);
    120124  }
    121125
    122   function segmented_post_hook($post_id, $post_attributes) {
     126  function segmented_post_hook($post_id, $post_attributes, $params) {
    123127    $post = get_post($post_id);
    124128
     
    128132      $post_attributes['post_title'] = $post_title;
    129133      $post_id = $this->join_segmented_posts($unique_identifier, $post_segment_number, $post, $post_attributes);
     134    }
     135
     136    if($params['post']['featured_image_attachment_id']) {
     137      set_post_thumbnail($post_id, $params['post']['featured_image_attachment_id']);
    130138    }
    131139
  • wordable/tags/8.0.5/includes/connector.php

    r2709892 r2713005  
    2424      'plugin_version' => WORDABLE_VERSION,
    2525      'wordpress_version' => get_bloginfo('version'),
    26       'authors' => $this->serialized_users(),
     26      'authors' => $this->serialized_authors(),
    2727      'categories' => $this->serialized_categories(),
    2828      'categories_tree' => $this->serialized_categories_tree(),
     
    3333  }
    3434
    35   function serialized_users() {
    36     $serialized_users = array();
     35  function serialized_authors() {
     36    $serialized_authors = array();
    3737
    38     foreach ($this->wordable_plugin->users() as $user) {
    39       if ($user->user_login == "") {
     38    foreach ($this->wordable_plugin->authors() as $author) {
     39      if ($author->author_login == "") {
    4040        continue;
    4141      }
    4242
    43       array_push($serialized_users, "$user->ID:$user->user_login");
     43      array_push($serialized_authors, "$author->ID:$author->author_login");
    4444    }
    4545
    46     return implode(',', $serialized_users);
     46    return implode(',', $serialized_authors);
    4747  }
    4848
  • wordable/tags/8.0.5/includes/wordable_plugin.php

    r2709892 r2713005  
    55  private $api_host_cache;
    66  private $secret_cache;
    7   private $users_cache;
     7  private $authors_cache;
    88  private $categories_cache;
    99  private $connector_instance;
     
    6161  }
    6262
    63   function users() {
    64     if(!$this->users_cache) {
    65       $this->users_cache = get_users(array(
    66         'roles_in' => 'author',
     63  function authors() {
     64    if(!$this->authors_cache) {
     65      $this->authors_cache = get_users(array(
     66        'role__in' => array('author'),
    6767        'fields' => array('ID', 'user_login', 'user_email', 'display_name'),
    6868        'number' => 200
     
    7070    }
    7171
    72     return $this->users_cache;
     72    return $this->authors_cache;
     73  }
     74
     75  function user_id_to_be_current() {
     76    foreach (array('administrator', 'editor', 'author', 'contributor') as $role) {
     77      $users = get_users(array(
     78        'role__in' => array('administrator'),
     79        'fields' => array('ID', 'user_login', 'user_email', 'display_name'),
     80        'number' => 1
     81      ));
     82
     83      if(count($users) == 1) {
     84        return $users[0]->ID;
     85      }
     86    }
    7387  }
    7488
  • wordable/tags/8.0.5/readme.txt

    r2710549 r2713005  
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    9 Stable Tag: 8.0.4
     9Stable Tag: 8.0.5
    1010
    1111This plugin allows you to instantly export Google Docs to WordPress posts or pages.
     
    5555
    5656== Changelog ==
     57
     58= 8.0.5 =
     59* Fetching only authors
     60* Not using users to upload images
     61* Set featured image
    5762
    5863= 8.0.4 =
  • wordable/tags/8.0.5/settings/views/authors.php

    r2681615 r2713005  
    1 <?php $users = $this->users(); ?>
     1<?php $authors = $this->authors(); ?>
    22
    3 <h1 class="heading-4">Authors (<?php echo count($users) ?>)</h1>
    4 <ul role="list" class="list w-list-unstyled">
    5   <?php foreach ($users as $user) { ?>
    6     <li class='list-item-3'>
    7       <div class='w-row'>
    8         <div class='w-col w-col-4 w-col-medium-6 w-col-small-6 w-col-tiny-6'>
    9              <div class='text-block-5'><?php echo esc_html($user->user_login) ?></div>
     3<h1 class="heading-4">Authors (<?php echo count($authors) ?>)</h1>
     4<div style="max-height: 50vh; overflow-y: auto">
     5  <ul role="list" class="list w-list-unstyled">
     6    <?php foreach ($authors as $author) { ?>
     7      <li class='list-item-3'>
     8        <div class='w-row'>
     9          <div class='w-col w-col-4 w-col-medium-6 w-col-small-6 w-col-tiny-6'>
     10               <div class='text-block-5'><?php echo esc_html($author->user_login) ?></div>
     11          </div>
     12          <div class='w-clearfix w-col w-col-8 w-col-medium-6 w-col-small-6 w-col-tiny-6'>
     13            <div class='div-block-5'>
     14               <a href='mailto:<?php echo $author->user_email ?>' class='link-block w-inline-block'>
     15                 <div class='text-block-6'><?php echo esc_html($author->user_email) ?></div>
     16               </a>
     17             </div>
     18           </div>
    1019        </div>
    11         <div class='w-clearfix w-col w-col-8 w-col-medium-6 w-col-small-6 w-col-tiny-6'>
    12           <div class='div-block-5'>
    13              <a href='mailto:<?php echo $user->user_email ?>' class='link-block w-inline-block'>
    14                <div class='text-block-6'><?php echo esc_html($user->user_email) ?></div>
    15              </a>
    16            </div>
    17          </div>
    18       </div>
    19     </li>
    20   <?php } ?>
    21 </ul>
     20      </li>
     21    <?php } ?>
     22  </ul>
     23</div>
  • wordable/tags/8.0.5/wordable.php

    r2710549 r2713005  
    44 * Plugin URI: http://wordable.io
    55 * Description: This plugin allows you to instantly export Google Docs to WordPress posts or pages.
    6  * Version: 8.0.4
     6 * Version: 8.0.5
    77 * Author: Wordable
    88 * Author URI: https://wordable.io
    99 * Tested up to: 5.9.2
    1010 * Requires at least: 5.0
    11  * Stable tag: 8.0.4
     11 * Stable tag: 8.0.5
    1212 *
    1313 * Wordpress 5.0+
    1414 */
    1515
    16 define('WORDABLE_VERSION', '8.0.4');
     16define('WORDABLE_VERSION', '8.0.5');
    1717
    1818include 'includes/wordable_plugin.php';
  • wordable/trunk/includes/action_params.php

    r2701468 r2713005  
    5757      $author_id = intval($this->params['post']['author_id']);
    5858
    59       if(!$this->user_exists($author_id)) {
     59      if(!$this->author_exists($author_id)) {
    6060        $this->params['post']['author_id'] = null;
    6161      } else {
     
    8181
    8282  // Helpers
    83   function user_exists($user_id) {
    84     foreach($this->wordable_plugin_actions->users() as $user) {
    85       if($user->ID == $user_id) {
     83  function author_exists($author_id) {
     84    foreach($this->wordable_plugin_actions->authors() as $author) {
     85      if($author->ID == $author_id) {
    8686        return true;
    8787      }
  • wordable/trunk/includes/actions.php

    r2701468 r2713005  
    4545  function action() {
    4646    $params = $this->parse_and_validate_params();
    47 
    48     if($params['post'] && $params['post']['author_id']) {
    49       wp_set_current_user($params['post']['author_id']);
    50     } else if (count($this->users()) > 0) {
    51       wp_set_current_user(array_values($this->users())[0]->ID);
    52     }
    5347
    5448    return $this->{$params['method'].'_action'}($params);
     
    106100
    107101  function create_post_action($params) {
     102    if($params['post'] && $params['post']['author_id']) {
     103      wp_set_current_user($params['post']['author_id']);
     104    } else {
     105      $current_user_id = $this->user_id_to_be_current();
     106
     107      if($current_user_id) {
     108        wp_set_current_user($current_user_id);
     109      }
     110    }
     111
    108112    $post_attributes = array(
    109113      'post_author' => $params['post']['author_id'],
     
    117121
    118122    $post_id = $this->throw_if_wp_error(wp_insert_post($post_attributes, true));
    119     return $this->segmented_post_hook($post_id, $post_attributes);
     123    return $this->segmented_post_hook($post_id, $post_attributes, $params);
    120124  }
    121125
    122   function segmented_post_hook($post_id, $post_attributes) {
     126  function segmented_post_hook($post_id, $post_attributes, $params) {
    123127    $post = get_post($post_id);
    124128
     
    128132      $post_attributes['post_title'] = $post_title;
    129133      $post_id = $this->join_segmented_posts($unique_identifier, $post_segment_number, $post, $post_attributes);
     134    }
     135
     136    if($params['post']['featured_image_attachment_id']) {
     137      set_post_thumbnail($post_id, $params['post']['featured_image_attachment_id']);
    130138    }
    131139
  • wordable/trunk/includes/connector.php

    r2709892 r2713005  
    2424      'plugin_version' => WORDABLE_VERSION,
    2525      'wordpress_version' => get_bloginfo('version'),
    26       'authors' => $this->serialized_users(),
     26      'authors' => $this->serialized_authors(),
    2727      'categories' => $this->serialized_categories(),
    2828      'categories_tree' => $this->serialized_categories_tree(),
     
    3333  }
    3434
    35   function serialized_users() {
    36     $serialized_users = array();
     35  function serialized_authors() {
     36    $serialized_authors = array();
    3737
    38     foreach ($this->wordable_plugin->users() as $user) {
    39       if ($user->user_login == "") {
     38    foreach ($this->wordable_plugin->authors() as $author) {
     39      if ($author->author_login == "") {
    4040        continue;
    4141      }
    4242
    43       array_push($serialized_users, "$user->ID:$user->user_login");
     43      array_push($serialized_authors, "$author->ID:$author->author_login");
    4444    }
    4545
    46     return implode(',', $serialized_users);
     46    return implode(',', $serialized_authors);
    4747  }
    4848
  • wordable/trunk/includes/wordable_plugin.php

    r2709892 r2713005  
    55  private $api_host_cache;
    66  private $secret_cache;
    7   private $users_cache;
     7  private $authors_cache;
    88  private $categories_cache;
    99  private $connector_instance;
     
    6161  }
    6262
    63   function users() {
    64     if(!$this->users_cache) {
    65       $this->users_cache = get_users(array(
    66         'roles_in' => 'author',
     63  function authors() {
     64    if(!$this->authors_cache) {
     65      $this->authors_cache = get_users(array(
     66        'role__in' => array('author'),
    6767        'fields' => array('ID', 'user_login', 'user_email', 'display_name'),
    6868        'number' => 200
     
    7070    }
    7171
    72     return $this->users_cache;
     72    return $this->authors_cache;
     73  }
     74
     75  function user_id_to_be_current() {
     76    foreach (array('administrator', 'editor', 'author', 'contributor') as $role) {
     77      $users = get_users(array(
     78        'role__in' => array('administrator'),
     79        'fields' => array('ID', 'user_login', 'user_email', 'display_name'),
     80        'number' => 1
     81      ));
     82
     83      if(count($users) == 1) {
     84        return $users[0]->ID;
     85      }
     86    }
    7387  }
    7488
  • wordable/trunk/readme.txt

    r2709892 r2713005  
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    9 Stable Tag: 8.0.4
     9Stable Tag: 8.0.5
    1010
    1111This plugin allows you to instantly export Google Docs to WordPress posts or pages.
     
    5555
    5656== Changelog ==
     57
     58= 8.0.5 =
     59* Fetching only authors
     60* Not using users to upload images
     61* Set featured image
    5762
    5863= 8.0.4 =
  • wordable/trunk/settings/views/authors.php

    r2681615 r2713005  
    1 <?php $users = $this->users(); ?>
     1<?php $authors = $this->authors(); ?>
    22
    3 <h1 class="heading-4">Authors (<?php echo count($users) ?>)</h1>
    4 <ul role="list" class="list w-list-unstyled">
    5   <?php foreach ($users as $user) { ?>
    6     <li class='list-item-3'>
    7       <div class='w-row'>
    8         <div class='w-col w-col-4 w-col-medium-6 w-col-small-6 w-col-tiny-6'>
    9              <div class='text-block-5'><?php echo esc_html($user->user_login) ?></div>
     3<h1 class="heading-4">Authors (<?php echo count($authors) ?>)</h1>
     4<div style="max-height: 50vh; overflow-y: auto">
     5  <ul role="list" class="list w-list-unstyled">
     6    <?php foreach ($authors as $author) { ?>
     7      <li class='list-item-3'>
     8        <div class='w-row'>
     9          <div class='w-col w-col-4 w-col-medium-6 w-col-small-6 w-col-tiny-6'>
     10               <div class='text-block-5'><?php echo esc_html($author->user_login) ?></div>
     11          </div>
     12          <div class='w-clearfix w-col w-col-8 w-col-medium-6 w-col-small-6 w-col-tiny-6'>
     13            <div class='div-block-5'>
     14               <a href='mailto:<?php echo $author->user_email ?>' class='link-block w-inline-block'>
     15                 <div class='text-block-6'><?php echo esc_html($author->user_email) ?></div>
     16               </a>
     17             </div>
     18           </div>
    1019        </div>
    11         <div class='w-clearfix w-col w-col-8 w-col-medium-6 w-col-small-6 w-col-tiny-6'>
    12           <div class='div-block-5'>
    13              <a href='mailto:<?php echo $user->user_email ?>' class='link-block w-inline-block'>
    14                <div class='text-block-6'><?php echo esc_html($user->user_email) ?></div>
    15              </a>
    16            </div>
    17          </div>
    18       </div>
    19     </li>
    20   <?php } ?>
    21 </ul>
     20      </li>
     21    <?php } ?>
     22  </ul>
     23</div>
  • wordable/trunk/wordable.php

    r2709892 r2713005  
    44 * Plugin URI: http://wordable.io
    55 * Description: This plugin allows you to instantly export Google Docs to WordPress posts or pages.
    6  * Version: 8.0.4
     6 * Version: 8.0.5
    77 * Author: Wordable
    88 * Author URI: https://wordable.io
    99 * Tested up to: 5.9.2
    1010 * Requires at least: 5.0
    11  * Stable tag: 8.0.4
     11 * Stable tag: 8.0.5
    1212 *
    1313 * Wordpress 5.0+
    1414 */
    1515
    16 define('WORDABLE_VERSION', '8.0.4');
     16define('WORDABLE_VERSION', '8.0.5');
    1717
    1818include 'includes/wordable_plugin.php';
Note: See TracChangeset for help on using the changeset viewer.