Skip to content

Commit

Permalink
Merge pull request #138 from PRX/feat/131-msn-start-plugin
Browse files Browse the repository at this point in the history
Installs Microsoft Start plugin for MSN feed
  • Loading branch information
brandonhundt authored Feb 12, 2024
2 parents 57e1007 + b4e18ff commit d30d8fe
Show file tree
Hide file tree
Showing 57 changed files with 4,811 additions and 9 deletions.
7 changes: 7 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'disable-comments/disable-comments.php',
'genesis-custom-blocks/genesis-custom-blocks.php',
'PATCH-external-media-without-import/external-media-without-import.php',
'microsoft-start/index.php',
'pwa/pwa.php',
'redirection/redirection.php',
'user-role-editor/user-role-editor.php',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-components', 'wp-i18n'), 'version' => '875d270491656edb4746');
3 changes: 3 additions & 0 deletions wp-content/plugins/microsoft-start/assets/js/callback.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions wp-content/plugins/microsoft-start/assets/js/callback.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-components', 'wp-i18n'), 'version' => '6dc543fd09a6e8e837a9');
38 changes: 38 additions & 0 deletions wp-content/plugins/microsoft-start/assets/js/dashboard.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions wp-content/plugins/microsoft-start/assets/js/dashboard.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-hooks', 'wp-i18n', 'wp-plugins'), 'version' => '4d7276a040d6dd538386');

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions wp-content/plugins/microsoft-start/assets/js/editorSidebar.js

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-components', 'wp-i18n'), 'version' => '542c225bcf6cb53cc393');
13 changes: 13 additions & 0 deletions wp-content/plugins/microsoft-start/assets/js/status.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions wp-content/plugins/microsoft-start/assets/js/status.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions wp-content/plugins/microsoft-start/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "microsoft/news",
"description": "",
"license": "",
"keywords": [],
"authors": [],
"require": {
"php": "^7.3|^8.0"
},
"autoload": {
"psr-4": {
"microsoft_start\\": ""
}
},
"autoload-dev": {
"psr-4": {
"microsoft_start\\tests\\": "../microsoft-start-tests"
}
},
"scripts": {
"test": "phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"minimum-stability": "dev"
}
74 changes: 74 additions & 0 deletions wp-content/plugins/microsoft-start/cron/BackgroundTasks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
// © Microsoft Corporation. All rights reserved.

namespace microsoft_start\cron;

use microsoft_start\infrastructure\Registration;
use microsoft_start\services\Options;

class BackgroundTasks extends Registration
{
function register_dependencies()
{
// 1.6.2: Temporarily disble adding cron job as it has some side effect; will re-enable after PM confirms
return;

add_action('wp', function () {
if (Options::get_share_past_posts_start_date()) {
if (!wp_next_scheduled('msnPublishTask')) {
wp_schedule_event(time(), 'hourly', 'msnPublishTask');
}
}
});

register_deactivation_hook(__FILE__, function () {
$timestamp = wp_next_scheduled('msnPublishTask');
wp_unschedule_event($timestamp, 'msnPublishTask');
});

add_action('msnPublishTask', [$this, 'publish_posts']);
}

function publish_posts()
{
// 1.6.2: clear the added cron job in previous version
wp_clear_scheduled_hook('msnPublishTask');
return;

if (!Options::get_share_past_posts_start_date()) {
return;
}

$now = gmdate('Y-m-d H:i:00');
$after = date_parse(Options::get_share_past_posts_start_date());

$posts = get_posts([
'post_type' => 'post',
'post_status' => ['publish', 'future'],
'meta_query' => [
[
'key' => 'msn_id',
'compare' => 'NOT EXISTS'
]
],
'date_query' => array(
array(
'after' => $after,
'before' => $now,
'inclusive' => true,
),
),
]);

foreach ($posts as $post) {
switch ($post->post_status) {
case 'future':
wp_publish_post($post->ID);
break;
case 'publish':
do_action( 'wp_after_insert_post', $post->ID, $post, true, null );
break;
}
}
}
}
Loading

0 comments on commit d30d8fe

Please sign in to comment.