Plugin Directory

Changeset 1826541


Ignore:
Timestamp:
02/21/2018 11:16:14 PM (8 years ago)
Author:
canvasflow
Message:

Add support for metabox and issues

Location:
canvasflow/trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • canvasflow/trunk/README.md

    r1805407 r1826541  
    5555
    5656#### Changelog
     57##### 0.11.0
     58* Add support for metabox in post editor
     59* Add support for issue in settings
     60
    5761##### 0.10.0
    5862* Add support for Wordpress shortcodes
     
    8892
    8993#### Upgrade Notice
     94##### 0.11.0
     95* Support for canvasflow as metabox in post editor
     96* Articles are add automatically to upload manager
     97* Users can now select a default issue
     98* Users can specify to which issue an post is going to be published
     99
    90100##### 0.10.0
    91101* Support Wordpress Shortcode
  • canvasflow/trunk/canvasflow-plugin.php

    r1805408 r1826541  
    33  Plugin Name: Canvasflow for WordPress
    44  Description: This out-of-the-box connector provides a quick and simple way to push your blog content directly to an existing Canvasflow publication.
    5   Version: 0.10.0
     5  Version: 0.11.0
    66    Developer:  Canvasflow
    77    Developer URI: https://canvasflow.io
     
    9393    }
    9494    function createCanvasflowPostsTable() {
    95         $query = "CREATE TABLE IF NOT EXISTS wp_canvasflow_posts(ID BIGINT(20) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,post_id BIGINT(20) UNSIGNED NOT NULL, style_id BIGINT(20) UNSIGNED, author_id BIGINT(20) UNSIGNED NOT NULL, published DATETIME, CONSTRAINT wp_canvasflow_posts_wp_posts_ID_fk FOREIGN KEY (post_id) REFERENCES wp_posts (ID) ON DELETE CASCADE ON UPDATE CASCADE);";
     95        $query = "CREATE TABLE IF NOT EXISTS wp_canvasflow_posts(ID BIGINT(20) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,post_id BIGINT(20) UNSIGNED NOT NULL, style_id BIGINT(20) UNSIGNED, issue_id BIGINT(20) UNSIGNED, author_id BIGINT(20) UNSIGNED NOT NULL, published DATETIME, CONSTRAINT wp_canvasflow_posts_wp_posts_ID_fk FOREIGN KEY (post_id) REFERENCES wp_posts (ID) ON DELETE CASCADE ON UPDATE CASCADE);";
    9696        $this->wpdb->query($query);
    9797    }
    9898    function createCanvasflowCredentialsTable() {
    99         $query = "CREATE TABLE IF NOT EXISTS wp_canvasflow_credentials (ID BIGINT(20) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT, user_id BIGINT(20) UNSIGNED NOT NULL, merge_adjacent_paragraphs BOOLEAN NOT NULL DEFAULT 1, secret_key TEXT, publication_id VARCHAR(100) NOT NULL DEFAULT '', style_id BIGINT(20) UNSIGNED, CONSTRAINT wp_canvasflow_credentials_wp_users_ID_fk FOREIGN KEY (user_id) REFERENCES wp_users (ID) ON DELETE CASCADE ON UPDATE CASCADE);";
     99        $query = "CREATE TABLE IF NOT EXISTS wp_canvasflow_credentials (ID BIGINT(20) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT, user_id BIGINT(20) UNSIGNED NOT NULL, merge_adjacent_paragraphs BOOLEAN NOT NULL DEFAULT 1, secret_key TEXT, publication_id VARCHAR(100) NOT NULL DEFAULT '', style_id BIGINT(20) UNSIGNED, issue_id BIGINT(20) UNSIGNED, CONSTRAINT wp_canvasflow_credentials_wp_users_ID_fk FOREIGN KEY (user_id) REFERENCES wp_users (ID) ON DELETE CASCADE ON UPDATE CASCADE);";
    100100        $this->wpdb->query($query);
    101101    }
     
    123123}
    124124new WP_Canvasflow();
     125
     126/* Define the custom box */
     127add_action( 'add_meta_boxes', 'canvasflow_add_custom_box');
     128
     129/* Do something with the data entered */
     130// add_action( 'save_post', 'myplugin_save_postdata' );
     131
     132/* Adds a box to the main column on the Post and Page edit screens */
     133function canvasflow_add_custom_box() {
     134    $title = 'Canvasflow';
     135    $screens = array( 'post', 'page');
     136    add_meta_box( 'cf_post', $title, 'cf_editor_meta_box' , $screens, 'side');
     137}
     138
     139/* Prints the box content */
     140function cf_editor_meta_box( $post ) {
     141
     142  // Use nonce for verification
     143    wp_nonce_field( plugin_basename( __FILE__ ), 'canvasflow_noncename' );
     144
     145    include( plugin_dir_path( __FILE__ ) . 'includes/canvasflow-metabox.php');
     146    $metaBox = new Canvasflow_Metabox();
     147    $metaBox->renderHTML($post);
     148
     149  // $field_value = get_post_meta( $post->ID, '_wp_editor_test_1', false );
     150  // wp_editor( $field_value[0], '_wp_editor_test_1' );
     151}
    125152?>
  • canvasflow/trunk/includes/canvasflow-main.php

    r1805407 r1826541  
    1919        private $publication_id;
    2020        private $default_style_id;
     21        private $default_issue_id;
    2122
    2223        function __construct($user_id) {
     
    2930            $this->publication_id = $credentials->publication_id;
    3031            $this->default_style_id = $credentials->style_id;
     32            $this->default_issue_id = $credentials->issue_id;
    3133        }
    3234
    3335        function get_user_credentials(){
    3436            $user_id = $this->user_id;
    35             $query = "SELECT secret_key, merge_adjacent_paragraphs, publication_id, style_id
    36             FROM wp_canvasflow_credentials LIMIT 1;";
     37            $query = "SELECT secret_key, merge_adjacent_paragraphs, publication_id, style_id, issue_id FROM wp_canvasflow_credentials LIMIT 1;";
    3738           
    3839            $credentials = $this->wpdb->get_results($query);
     
    4546                $credential->publication_id = '';
    4647                $credential->style_id = '';
     48                $credential->issue_id = '';
    4749                return $credential;
    4850            }
     
    5658            $publication_id = $this->publication_id;
    5759            $default_style_id = $this->default_style_id;
     60            $default_issue_id = $this->default_issue_id;
    5861
    5962            $page = $this->page;
     
    6871                foreach($this->get_styles_from_remote($publication_id, $secret_key) as $style) {
    6972                    array_push($styles, $style);
     73                }
     74
     75                $issues = array();
     76                foreach($this->get_issues_from_remote($publication_id, $secret_key) as $issue) {
     77                    array_push($issues, $issue);
    7078                }
    7179
     
    132140                users.display_name as display_name, users.ID as user_id, canvasflow_posts.published as published,
    133141                canvasflow_posts.ID as canvasflow_post_id, post.post_modified as post_modified_date, post.post_type
    134                 as type, canvasflow_posts.style_id as style_id FROM {$post_table_name} as post LEFT JOIN {$users_table_name} as users
     142                as type, canvasflow_posts.style_id as style_id, canvasflow_posts.issue_id as issue_id FROM {$post_table_name} as post LEFT JOIN {$users_table_name} as users
    135143                ON(post.post_author=users.ID) LEFT JOIN wp_canvasflow_posts as canvasflow_posts
    136144                ON(post.ID=canvasflow_posts.post_id)  WHERE post.post_parent = 0 AND (post.post_type = \"post\"
     
    143151                    users.display_name as display_name, users.ID as user_id, canvasflow_posts.published as published,
    144152                    canvasflow_posts.ID as canvasflow_post_id, post.post_modified as post_modified_date, post.post_type
    145                     as type, canvasflow_posts.style_id as style_id FROM {$post_table_name} as post LEFT JOIN {$users_table_name} as users
     153                    as type, canvasflow_posts.style_id as style_id, canvasflow_posts.issue_id as issue_id FROM {$post_table_name} as post LEFT JOIN {$users_table_name} as users
    146154                    ON(post.post_author=users.ID) LEFT JOIN wp_canvasflow_posts as canvasflow_posts
    147155                    ON(post.ID=canvasflow_posts.post_id)  WHERE post.post_parent = 0 AND (post.post_type = \"post\" OR
     
    162170                users.display_name as display_name, users.ID as user_id, canvasflow_posts.published as published,
    163171                canvasflow_posts.ID as canvasflow_post_id, post.post_modified as post_modified_date,
    164                 canvasflow_posts.style_id as style_id FROM {$post_table_name} as post LEFT JOIN {$users_table_name} as users
     172                canvasflow_posts.style_id as style_id, canvasflow_posts.issue_id as issue_id FROM {$post_table_name} as post LEFT JOIN {$users_table_name} as users
    165173                ON(post.post_author=users.ID) LEFT JOIN wp_canvasflow_posts as canvasflow_posts
    166174                ON(post.ID=canvasflow_posts.post_id)  WHERE post.post_parent = 0 AND (post.post_type = \"post\"
     
    171179                    as content,  users.display_name as display_name, users.ID as user_id, canvasflow_posts.published as
    172180                    published, canvasflow_posts.ID as canvasflow_post_id, post.post_modified as post_modified_date,
    173                     canvasflow_posts.style_id as style_id FROM {$post_table_name} as post LEFT JOIN {$users_table_name} as users
     181                    canvasflow_posts.style_id as style_id, canvasflow_posts.issue_id as issue_id FROM {$post_table_name} as post LEFT JOIN {$users_table_name} as users
    174182                    ON(post.post_author=users.ID) LEFT JOIN wp_canvasflow_posts as canvasflow_posts
    175183                    ON(post.ID=canvasflow_posts.post_id)  WHERE post.post_parent = 0 AND (post.post_type = \"post\" OR
     
    188196        }
    189197
    190         function send_post($post_id, $style_id) {
     198        function send_post($post_id, $style_id, $issue_id) {
    191199            $author_id = wp_get_current_user()->ID;
    192200            $post = get_post($post_id);
    193201            $post_title = $post->post_title;
    194202            $post_content = $post->post_content;
    195             if($this->publish_post($post_content, $post_title, $post_id, $style_id)){
    196                 $this->update_post($post_id, $style_id);
    197             }
    198         }
    199 
    200         function publish_post($content, $post_title, $post_id, $style_id) {
     203            if($this->publish_post($post_content, $post_title, $post_id, $style_id, $issue_id)){
     204                $this->update_post($post_id, $style_id, $issue_id);
     205            }
     206        }
     207
     208        function publish_post($content, $post_title, $post_id, $style_id, $issue_id) {
    201209            $secret_key = $this->secret_key;
    202210            $merge_adjacent_paragraphs = $this->merge_adjacent_paragraphs;
     
    217225
    218226            $style_id = (int) $style_id;
     227            $issue_id = (int) $issue_id;
    219228
    220229            $content = do_shortcode($content);
     
    228237                'contentType' => "html",
    229238                'publicationId' => $publication_id,
    230                 'issueId' => "Iss01",
     239                'issueId' => $issue_id,
    231240                'mergeAdjParagraphs' => $merge_adjacent_paragraphs,
    232241                'styleId' => $style_id,
     
    266275        }
    267276
    268         function update_post($post_id, $style_id){
     277        function update_post($post_id, $style_id, $issue_id){
    269278            $author_id = $this->user_id;
    270279
    271280            $time = current_time( 'mysql' );
    272             $query = "UPDATE wp_canvasflow_posts SET author_id = {$author_id}, published = '{$time}', style_id = {$style_id}
    273             WHERE post_id = {$post_id};";
     281            $query = "INSERT INTO wp_canvasflow_posts (post_id, author_id, published, style_id, issue_id) VALUES ({$post_id}, {$author_id}, '{$time}', {$style_id}, {$issue_id});"; 
     282           
     283            if($this->exist_post($post_id)) {
     284                $query = "UPDATE wp_canvasflow_posts SET author_id = {$author_id}, published = '{$time}', style_id = {$style_id}, issue_id = {$issue_id} WHERE post_id = {$post_id};";
     285            }
     286
    274287            $this->wpdb->query($query);
     288
     289        }
     290
     291        function exist_post($post_id) {
     292            $query = "SELECT * FROM wp_canvasflow_posts WHERE post_id = {$post_id};";
     293            $result = $this->wpdb->get_results($query);
     294            if(sizeof($result) > 0) {
     295                return TRUE;
     296            }
     297            return FALSE;
    275298        }
    276299
     
    294317            }
    295318        }
     319
     320        function get_issues_from_remote($publication_id, $secret_key) {
     321            $url = $this->base_url."/issues?secretkey={$secret_key}&publicationId={$publication_id}";
     322            $response = wp_remote_get($url);
     323
     324            if ( is_wp_error( $response ) ) {
     325                $error_message = $response->get_error_message();
     326                echo "<div class=\"error-message\"><div><b>{$error_message}</div></div>";
     327            } else {
     328                $http_response_code = $response['response']['code'];
     329                $body = $response['body'];
     330                if($http_response_code == 200){
     331                    return json_decode($body, true);
     332                } else {
     333                    $message = $body;
     334                    $message = str_replace('"', '', $message);
     335                    echo "<div class=\"error-message\"><div><b>{$message}</b></div></div>";
     336                }
     337            }
     338        }
    296339    }
    297340
    298341    $canvasflow_main = new Canvasflow_Main($user_id);
    299342    if(isset($_POST["id"])) {
    300         $canvasflow_main->send_post($_POST["id"], $_POST["style_id"]);
     343        $canvasflow_main->send_post($_POST["id"], $_POST["style_id"], $_POST["issue_id"]);
    301344    }
    302345
  • canvasflow/trunk/includes/canvasflow-settings.php

    r1736456 r1826541  
    1818        private $publications = array();
    1919        private $style_id = 0;
     20        private $issue_id = 0;
    2021        private $styles = array();     
     22        private $issues = array();
    2123        private $valid_secret_key = TRUE;
    2224       
     
    3436                $db_publication_id = $credentials->publication_id;
    3537                $db_style_id = $credentials->style_id;
     38                $db_issue_id = $credentials->issue_id;
    3639
    3740                $this->merge_adjacent_paragraphs = $db_merge_adjacent_paragraphs;
     
    4144                    $this->publications = array();
    4245                    foreach($this->get_remote_publications($db_secret_key) as $publication) {
    43                         if($publication['type'] == 'article') {
     46                        array_push($this->publications, $publication);
     47                        /*if($publication['type'] == 'article') {
    4448                            array_push($this->publications, $publication);
    45                         }
     49                        }*/
    4650                    }
    4751
     
    5963                            $this->style_id = $this->styles[0]['id'];
    6064                        }
     65
     66                        $this->issues = array();
     67                        foreach($this->get_remote_issues($db_secret_key, $this->publication_id) as $issue) {
     68                            array_push($this->issues, $issue);
     69                        }
     70
     71                        if($db_issue_id != '') {
     72                            $this->issue_id = $db_issue_id;
     73                        } else {
     74                            $this->issue_id = $this->issues[0]['id'];
     75                        }
    6176                    } else {
    6277                        $this->style_id = '';
    6378                        $this->styles = array();
     79
     80                        $this->db_issue_id = '';
     81                        $this->issues = array();
    6482                    }
    6583                }
     
    6987                $this->style_id = '';
    7088                $this->styles = array();
    71             }
    72         }
    73 
    74         public function update_credentials($request_secret_key, $request_merge_adjacent_paragraphs, $request_publication_id, $request_style_id) {
     89                $this->db_issue_id = '';
     90                $this->issues = array();
     91            }
     92        }
     93
     94        public function update_credentials($request_secret_key, $request_merge_adjacent_paragraphs, $request_publication_id, $request_style_id, $request_issue_id) {
    7595            $credentials = $this->get_user_credentials();
    7696            $db_secret_key = $credentials->secret_key;
    7797            $db_publication_id = $credentials->publication_id;
    7898            $db_style_id = $credentials->style_id;
     99            $db_issue_id = $credentials->issue_id;
    79100
    80101            $this->merge_adjacent_paragraphs = $request_merge_adjacent_paragraphs;
     
    84105                    $this->update_secret_key($request_secret_key);
    85106                    $this->reset_canvasflow_posts_style();
     107                    $this->reset_canvasflow_posts_issue();
    86108                } else {
    87109                    $this->secret_key = $request_secret_key;
     
    89111                        $this->update_publication($request_publication_id);
    90112                        $this->reset_canvasflow_posts_style();
     113                        $this->reset_canvasflow_posts_issue();
    91114                    } else {
    92115                        $this->publication_id = $request_publication_id;
     
    96119                            $this->style_id = $db_style_id;
    97120                        }
    98                     }
    99                 }
    100 
    101                 $this->save_credentials($this->secret_key, $this->merge_adjacent_paragraphs, $this->publication_id, $this->style_id);
     121
     122                        if($db_issue_id != $request_issue_id) {
     123                            $this->issue_id = $request_issue_id;
     124                        } else {
     125                            $this->issue_id = $db_issue_id;
     126                        }
     127                    }
     128                }
     129
     130                $this->save_credentials($this->secret_key, $this->merge_adjacent_paragraphs, $this->publication_id, $this->style_id, $this->issue_id);
    102131            } else {
    103132                $this->valid_secret_key = FALSE;
     
    112141            $this->publications = array();
    113142            $this->style_id = 0;
     143            $this->issue_id = 0;
    114144            $this->styles = array(); 
     145            $this->issues = array();
    115146        }
    116147
     
    129160
    130161            $this->style_id = $this->styles[0]['id'];
     162
     163            $this->issues = array();
     164            foreach($this->get_remote_issues($this->secret_key, $this->publication_id) as $issue) {
     165                array_push($this->issues, $issue);
     166            }
     167
     168            $this->issue_id = $this->issues[0]['id'];
    131169        }
    132170
     
    139177
    140178            $selected_style = $this->style_id;
     179            $selected_issue = $this->issue_id;
     180
    141181            $styles = $this->styles;
     182            $issues = $this->issues;
    142183
    143184            include( plugin_dir_path( __FILE__ ) . 'views/canvasflow-settings-view.php');
     
    147188            $user_id = $this->user_id;
    148189            //$query = "SELECT secret_key, merge_adjacent_paragraphs, publication_id, style_id FROM {$db_name}.wp_canvasflow_credentials WHERE user_id = {$user_id}; LIMIT 1;";
    149             $query = "SELECT secret_key, merge_adjacent_paragraphs, publication_id, style_id FROM wp_canvasflow_credentials LIMIT 1;";
     190            $query = "SELECT secret_key, merge_adjacent_paragraphs, publication_id, style_id, issue_id FROM wp_canvasflow_credentials LIMIT 1;";
    150191            $this->wpdb->query($query);
    151192           
     
    159200                $credential->publication_id = '';
    160201                $credential->style_id = '';
     202                $credential->issue_id = '';
    161203                return $credential;
    162204            }
     
    229271        }
    230272
    231         private function save_credentials($secret_key, $merge_adjacent_paragraphs, $publication_id, $style_id){
     273        private function get_remote_issues($secret_key, $publication_id) {
     274            $url = $this->base_url."/issues?secretkey={$secret_key}&publicationId={$publication_id}";
     275            $response = wp_remote_get($url);
     276
     277            if ( is_wp_error( $response ) ) {
     278                $error_message = $response->get_error_message();
     279                echo "<div class=\"error-message\"><div><b>{$error_message}</div></div>";
     280            } else {
     281                $http_response_code = $response['response']['code'];
     282                $body = $response['body'];
     283                if($http_response_code == 200){
     284                    if($body == "array()"){
     285                        $message = "There are no issues for this publication";
     286                        echo "<div class=\"error-message\"><div><b>{$message}</b></div></div>";
     287                    }
     288                    return json_decode($body, true);
     289                } else {
     290                    $message = $body;
     291                    $message = str_replace('"', '', $message);
     292                    echo "<div class=\"error-message\"><div><b>{$message}</b></div></div>";
     293                }
     294            }
     295        }
     296
     297        private function save_credentials($secret_key, $merge_adjacent_paragraphs, $publication_id, $style_id, $issue_id){
    232298            if($this->exist_credentials()) {
    233299                $this->insert_credentials_in_db($secret_key, $merge_adjacent_paragraphs);
    234300            } else {
    235                 $this->update_credentials_in_db($secret_key, $merge_adjacent_paragraphs, $publication_id, $style_id);
     301                $this->update_credentials_in_db($secret_key, $merge_adjacent_paragraphs, $publication_id, $style_id, $issue_id);
    236302            }
    237303        }
     
    251317        private function insert_credentials_in_db($secret_key, $merge_adjacent_paragraphs = 0) {
    252318            $user_id = $this->user_id;
    253             $query = "INSERT INTO wp_canvasflow_credentials (user_id, secret_key, merge_adjacent_paragraphs, publication_id, style_id) VALUES ({$user_id}, \"{$secret_key}\", {$merge_adjacent_paragraphs}, \"\", NULL);";
    254             $this->wpdb->query($query);
    255         }
    256 
    257         private function update_credentials_in_db($secret_key, $merge_adjacent_paragraphs = 1, $publication_id = '', $style_id = 0) {
     319            $query = "INSERT INTO wp_canvasflow_credentials (user_id, secret_key, merge_adjacent_paragraphs, publication_id, style_id, issue_id) VALUES ({$user_id}, \"{$secret_key}\", {$merge_adjacent_paragraphs}, \"\", NULL, NULL);";
     320            $this->wpdb->query($query);
     321        }
     322
     323        private function update_credentials_in_db($secret_key, $merge_adjacent_paragraphs = 1, $publication_id = '', $style_id = 0, $issue_id = 0) {
    258324            $user_id = $this->user_id;
    259325           
     
    264330
    265331            if($style_id == 0) {
    266                 $query = "UPDATE wp_canvasflow_credentials SET secret_key = \"{$secret_key}\", merge_adjacent_paragraphs = {$merge_adjacent_paragraphs}, publication_id = \"{$publication_id}\", style_id = NULL;";
    267             } else {
    268                 $query = "UPDATE wp_canvasflow_credentials SET secret_key = \"{$secret_key}\", merge_adjacent_paragraphs = {$merge_adjacent_paragraphs}, publication_id = \"{$publication_id}\", style_id = {$style_id};";
     332                $query = "UPDATE wp_canvasflow_credentials SET secret_key = \"{$secret_key}\", merge_adjacent_paragraphs = {$merge_adjacent_paragraphs}, publication_id = \"{$publication_id}\", style_id = NULL";
     333            } else {
     334                $query = "UPDATE wp_canvasflow_credentials SET secret_key = \"{$secret_key}\", merge_adjacent_paragraphs = {$merge_adjacent_paragraphs}, publication_id = \"{$publication_id}\", style_id = {$style_id}";
     335            }
     336
     337            if($issue_id == 0) {
     338                $query .= ", issue_id = NULL;";
     339            } else {
     340                $query .= ", issue_id = {$issue_id};";
    269341            }
    270342
     
    275347            $user_id = $this->user_id;
    276348            $query = "UPDATE wp_canvasflow_posts SET style_id = NULL;";
     349            $this->wpdb->query($query);
     350        }
     351
     352        private function reset_canvasflow_posts_issue() {
     353            $user_id = $this->user_id;
     354            $query = "UPDATE wp_canvasflow_posts SET issue_id = NULL;";
    277355            $this->wpdb->query($query);
    278356        }
     
    302380            }
    303381
    304             $canvasflow_settings->update_credentials($secret_key, $merge_adjacent_paragraphs, $publication_id, $style_id);
     382            $issue_id = '';
     383            if(isset($_POST["issue_id"])) {
     384                $issue_id = $_POST["issue_id"];
     385            }
     386
     387            $canvasflow_settings->update_credentials($secret_key, $merge_adjacent_paragraphs, $publication_id, $style_id, $issue_id);
    305388            echo "<div class=\"success-message\"><div><b>Settings Updated</b></div></div>";
    306389        }catch(Exception $e) {
  • canvasflow/trunk/includes/views/canvasflow-main-view.php

    r1714764 r1826541  
    143143                        <span>Style</span>
    144144                    </th>
     145                    <th scope="col" id="issues" class="manage-column column-author num sortable desc">
     146                        <span>Issue</span>
     147                    </th>
    145148                    <th scope="col" id="styles" class="manage-column column-author num sortable desc">
    146149                            <?php
     
    206209                        $post_modified_date = $post->post_modified_date;
    207210                        $current_style_id = $post->style_id;
     211                        $current_issue_id = $post->issue_id;
    208212                        if($post->style_id == '') {
    209213                            $current_style_id = $default_style_id;
     214                        }
     215                        if($post->issue_id == '') {
     216                            $current_issue_id = $default_issue_id;
    210217                        }
    211218
     
    276283                        ?>
    277284                    </td>
     285                    <td class="date column-author" data-colname="Style">
     286                       
     287                        <?php 
     288                            $issue_select = "<select class=\"selectpicker\" name=\"issue_id\" style=\"position: relative; width: 100%\" required>";
     289                            foreach($issues as $issue) {
     290                                $id = $issue['id'];
     291                                $issue_name = $issue['name'];
     292                                if($id == $current_issue_id) {
     293                                    $issue_select.= '<option value="'.$id.'" selected name="'.$current_issue_id.'">'.$issue_name.'</option>';
     294                                } else {
     295                                    $issue_select.= '<option value="'.$id.'">'.$issue_name.'</option>';
     296                                }
     297                            }
     298                            $issue_select.= "</select>";
     299                            echo $issue_select;
     300                        ?>
     301                    </td>
    278302                    <td class="date column-author" data-colname="Type">
    279303                        <div><?php echo $type;?></div>
  • canvasflow/trunk/includes/views/canvasflow-settings-view.php

    r1699142 r1826541  
    5959                    </td>
    6060                </tr>
     61                <?php
     62                    if(count($issues) > 0) {
     63
     64                   
     65                ?>
     66                <tr>
     67                    <th scope="row">
     68                        <label for="style_id">Default Issue</label>
     69                    </th>
     70                    <td>
     71                        <select class="selectpicker" name="issue_id" required>
     72                        <?php
     73                            $select_option_issue = '';
     74                            foreach ($issues as $issue) {
     75                                $issue_id = $issue['id'];
     76                                $issue_name = $issue['name'];
     77                                if($issue_id == $selected_issue) {
     78                                    $select_option_issue.= '<option value="'.$issue_id.'" selected>'.$issue_name.'</option>';
     79                                } else {
     80                                    $select_option_issue.= '<option value="'.$issue_id.'">'.$issue_name.'</option>';
     81                                }
     82                            }
     83
     84                            echo $select_option_issue;
     85                        ?>
     86                        </select>
     87                        <br/>
     88                        <small>
     89                            <em>
     90                                Determines the default issue where the article is going to be uploaded.
     91                            </em>
     92                        </small>
     93                    </td>
     94                </tr>
     95                <?php
     96
     97                    }
     98                ?>
    6199                <?php
    62100                    if(count($styles) > 0){
    63                        
    64101                ?>
    65102                <tr>
  • canvasflow/trunk/readme.txt

    r1805407 r1826541  
    7070
    7171== Changelog ==
     72= 0.11.0 =
     73* Add support for metabox in post editor
     74* Add support for issue in settings
     75
    7276= 0.10.0 =
    7377Add support for Wordpress shortcodes
     
    102106
    103107== Upgrade Notice ==
     108= 0.11.0 =
     109Support for canvasflow as metabox in post editor
     110Articles are add automatically to upload manager
     111Users can now select a default issue
     112Users can specify to which issue an post is going to be published
     113
    104114= 0.10.0 =
    105115Support Wordpress Shortcode
Note: See TracChangeset for help on using the changeset viewer.