Skip to content

Commit

Permalink
all page sync fix
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhantdante committed Sep 13, 2020
1 parent d953a30 commit fac77d8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 58 deletions.
59 changes: 59 additions & 0 deletions Wordpress Plugin/utils/monday-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,63 @@ function keys_refresh() {

add_action( 'wp_ajax_keys_refresh', 'keys_refresh' );

//create page or post
function process_post_or_page( $type, $board_id ) {

$args = array(
'numberposts' => - 1,
'post_type' => array( $type ),
'orderby' => 'title',
'order' => 'ASC',
'post_status' => array( 'pending', 'draft', 'future', 'publish' )
);

$posts_array = get_posts( $args );

foreach ( $posts_array as $post ) {

//sync post comments
//sync_post_comments( $post->ID );

// get post tags
$tags = get_post_tags_array( $post->ID );

// get post categories
$categories = get_post_categories_array( $post->ID );

if ( $post->post_status == 'publish' ) {
$status = 1;
} else {
$status = 0;
}

if ( empty( get_monday_user_id( $post->post_author ) ) ) {
$authors = array();
} else {
$authors = array(
array(
'id' => get_monday_user_id( $post->post_author ),
'kind' => 'person'
)
);
}

$post_array = array(
'name' => $post->post_title,
'author' => array(
'personsAndTeams' => $authors
),
'tags' => array( 'tag_ids' => $tags ),
'category' => array( 'tag_ids' => $categories ),
'status' => array( 'index' => $status ),
'date' => array(
'date' => get_the_date( 'Y-m-d', $post->ID ),
'time' => get_the_time( 'G:i:s', $post->ID )
),
'post_link' => array( 'url' => get_post_permalink( $post->ID ), 'text' => $post->post_title ),
);

update_or_create_content_auto_synch( $board_id, $post_array, $post );

}
}
63 changes: 5 additions & 58 deletions Wordpress Plugin/utils/post-synch.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,70 +12,17 @@ function sync_post() {
//for create post subscription
foreach ( get_board_ids( 'create_post' ) as $board_id ) {

$args = array(
'numberposts' => - 1,
'post_type' => array( 'post' ),
'orderby' => 'title',
'order' => 'ASC',
'post_status' => array( 'pending', 'draft', 'future', 'publish' )
);
$posts_array = get_posts( $args );
process_post_or_page( 'post', $board_id );

foreach ( $posts_array as $post ) {

//sync post comments
//sync_post_comments( $post->ID );

// get post tags
$tags = get_post_tags_array( $post->ID );

// get post categories
$categories = get_post_categories_array( $post->ID );

if ( $post->post_status == 'publish' ) {
$status = 1;
} else {
$status = 0;
}

if ( empty( get_monday_user_id( $post->post_author ) ) ) {
$authors = array();
} else {
$authors = array(
array(
'id' => get_monday_user_id( $post->post_author ),
'kind' => 'person'
)
);
}

$post_array = array(
'name' => $post->post_title,
'author' => array(
'personsAndTeams' => $authors
),
'tags' => array( 'tag_ids' => $tags ),
'category' => array( 'tag_ids' => $categories ),
'status' => array( 'index' => $status ),
'date' => array(
'date' => get_the_date( 'Y-m-d', $post->ID ),
'time' => get_the_time( 'G:i:s', $post->ID )
),
'post_link' => array( 'url' => get_post_permalink( $post->ID ), 'text' => $post->post_title ),
);
}

update_or_create_content_auto_synch( $board_id, $post_array, $post );
//for create page subscription
foreach ( get_board_ids( 'create_page' ) as $board_id ) {

}
process_post_or_page( 'page', $board_id );

}

//for create page subscription
// foreach ( get_board_ids( 'create_page' ) as $board_id ) {
//
//
// }

die();
}

Expand Down

0 comments on commit fac77d8

Please sign in to comment.