Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to Test feeds and perform manual pulls via AJAX with log response #15

Open
wants to merge 45 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a127804
Update contributor list
tlovett1 Jan 14, 2015
be63502
Add ability to Test feeds and AJAX load the log when doing manual pull
sc0ttkclark Jan 31, 2015
eca48f0
Merge branch 'master' into pull-test
sc0ttkclark Jan 31, 2015
f1550b9
Fix text domain
sc0ttkclark Feb 2, 2015
19d2855
Fix textdomain that was empty
sc0ttkclark Feb 2, 2015
09a0f0b
Update since version number
sc0ttkclark Feb 2, 2015
81e21d6
Merge branch 'develop' into pull-test
sc0ttkclark Feb 2, 2015
c5b4787
Fix CSS change that made it into last commit batch
sc0ttkclark Feb 2, 2015
9050dab
CSS tweak
sc0ttkclark Feb 2, 2015
47e6d80
CSS tweak again
sc0ttkclark Feb 2, 2015
4718d70
Every little thing CSS
sc0ttkclark Feb 2, 2015
be3e224
Merge branch 'master' into pull-test
sc0ttkclark Feb 2, 2015
a13d9c1
Rebuild CSS from PR #3
sc0ttkclark Feb 2, 2015
6392f59
phpdoc for $wpdb usage
sc0ttkclark Feb 2, 2015
6bbc6fc
Remove todo marker that's no longer needed
sc0ttkclark Feb 2, 2015
a0799e8
get_feed_posts now processes mapped fields instead of only passing ba…
sc0ttkclark Feb 2, 2015
2abf059
Remove unnecessary calls
sc0ttkclark Feb 2, 2015
22edcdb
Manual pull now throws an error if feed not published
sc0ttkclark Feb 2, 2015
f7764a9
Fix field mapping keys
sc0ttkclark Feb 2, 2015
fbccc2c
Remove mapping file reference from build
sc0ttkclark Feb 2, 2015
6f11a23
One more layer of abstraction, to make the world a better place for t…
sc0ttkclark Feb 2, 2015
b4877bc
Abstract fp_fetch_feed into FP_Pull::fetch_feed
sc0ttkclark Feb 2, 2015
8073a96
Call FP_Pull::fetch_feed statically
sc0ttkclark Feb 2, 2015
56a2dae
Merge pull request #5 from sc0ttkclark/pull-test
tlovett1 Feb 3, 2015
b5b5cec
Increment to version 1.0
tlovett1 Feb 3, 2015
30a1ce6
Add support for user agent override in the request args for wp_remote…
sc0ttkclark Feb 5, 2015
8e0a00c
Merge pull request #10 from sc0ttkclark/feature/filter-user-agent
tlovett1 Feb 5, 2015
57fded3
Check if $feed is strictly false to detect if feed was not parsed
sc0ttkclark Feb 10, 2015
62f8c2d
Merge pull request #12 from sc0ttkclark/feature/fix-feed-parse-false
tlovett1 Feb 10, 2015
bf92795
Setup Dockunit
tlovett1 Feb 18, 2015
6acc001
Merge branch 'develop' of github.com:tlovett1/feed-pull into develop
tlovett1 Feb 18, 2015
61ea538
Update dockunit
tlovett1 Feb 19, 2015
d8e8ed8
Add dockunit to readme
tlovett1 Feb 25, 2015
0262bcf
Refactor readme
tlovett1 Feb 25, 2015
b69e2c9
Setup Dockunit
tlovett1 Feb 25, 2015
a1e2383
Fix built css to show minor pubishing actions
tlovett1 Mar 23, 2015
5c7b8c2
Use {{ }} style templates for Backbone
tlovett1 Mar 23, 2015
250db0f
Add source map
tlovett1 Mar 23, 2015
aa82281
Version 0.2.5
tlovett1 Mar 23, 2015
fd02912
Add sourceMappingURL from previous commit
sc0ttkclark Apr 2, 2015
c0b0870
Merge branch 'develop' into feature/feed-test
sc0ttkclark Apr 2, 2015
6318a95
Fix npm install issue with bad version format (needs to be x.x.x)
sc0ttkclark Apr 2, 2015
4d45897
Allow for manual pulls that bypass enable_feed_pull option
sc0ttkclark Mar 11, 2015
e4588b4
AJAX manual pull should bypass enable_feed_pull option
sc0ttkclark Mar 11, 2015
48745bc
Fix do_pull usage for AJAX testing
sc0ttkclark Apr 3, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build/css/post-admin.css
100644 → 100755

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

2 changes: 1 addition & 1 deletion build/css/post-admin.css.map

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

2 changes: 1 addition & 1 deletion build/css/post-admin.min.css
100644 → 100755

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

2 changes: 1 addition & 1 deletion build/js/post-admin.min.js
100644 → 100755

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

Empty file modified build/js/settings-admin.min.js
100644 → 100755
Empty file.
78 changes: 75 additions & 3 deletions includes/class-fp-ajax.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FP_AJAX {
*/
private function __construct() {
add_action( 'wp_ajax_pull', array( $this, 'action_pull' ) );
add_action( 'wp_ajax_pull_test', array( $this, 'action_pull_test' ) );
add_action( 'wp_ajax_reset_deleted_posts', array( $this, 'action_reset_deleted_posts' ) );
add_action( 'wp_ajax_get_namespaces', array( $this, 'action_get_namespaces' ) );
}
Expand All @@ -29,7 +30,7 @@ public function action_get_namespaces() {
$output['success'] = false;

if ( ! empty( $_POST['feed_url'] ) && check_ajax_referer( 'fp_get_namespaces_nonce', 'nonce', false ) ) {
$raw_feed_contents = fp_fetch_feed( $_POST['feed_url'] );
$raw_feed_contents = FP_Pull::fetch_feed( $_POST['feed_url'] );

if ( ! is_wp_error( $raw_feed_contents ) ) {
$feed = simplexml_load_string( $raw_feed_contents );
Expand All @@ -52,16 +53,87 @@ public function action_get_namespaces() {
*/
public function action_pull() {
$output = array();
$output['message'] = __( 'Invalid AJAX Request, try again.', 'feed-pull' );
$output['success'] = false;

if ( check_ajax_referer( 'fp_pull_nonce', 'nonce', false ) ) {
$source_feed_id = null;

if ( isset( $_POST['source_feed_id'] ) ) {
$source_feed_id = (int) $_POST['source_feed_id'];
}

new FP_Pull( $source_feed_id );
$output['success'] = true;
if ( 'publish' != get_post_status( $source_feed_id ) ) {
$output['message'] = __( 'Feed must be published in order to do a manual pull.', 'feed-pull' );

$output['success'] = false;
}
else {
$fp = new FP_Pull( false );

// Do manual pull
$fp->do_pull( $source_feed_id, true );

$feed_cpt = FP_Source_Feed_CPT::factory();

$source_feed = get_post( $source_feed_id );

ob_start();

$feed_cpt->meta_box_log( $source_feed );

$output['message'] = ob_get_clean();

$output['success'] = true;
}
}

wp_send_json( $output );
}

/**
* Do a feed pull test
*
* @since 1.0.0
* @return void
*/
public function action_pull_test() {
$output = array();
$output['success'] = false;

if ( check_ajax_referer( 'fp_pull_nonce', 'nonce', false ) ) {
$source_feed_id = null;

if ( isset( $_POST['source_feed_id'] ) ) {
$source_feed_id = (int) $_POST['source_feed_id'];
}

$feedpull = new FP_Pull( false );

$posts = $feedpull->get_feed_posts( $source_feed_id );

// Error
if ( false === $posts ) {
$feed_cpt = FP_Source_Feed_CPT::factory();

$source_feed = get_post( $source_feed_id );

ob_start();

$feed_cpt->meta_box_log( $source_feed );

$output['message'] = ob_get_clean();

$output['success'] = false;
}
else {
// Get first post
$content = current( $posts );

$output['message'] = print_r( $content, true );

$output['success'] = true;
}
}

wp_send_json( $output );
Expand Down
Loading