Skip to content

Commit

Permalink
Merge pull request #488 from Codeinwp/v850
Browse files Browse the repository at this point in the history
New PRO: Made it easier to connect LinkedIn Accounts for New Users
New PRO: Plugin will now grab LinkedIn company pages using LinkedIn service in ROP dashboard
New PRO: Easier addition of Instagram accounts and Facebook Groups using Buffer integration
New PRO: Ability to add custom images to post share variations
Fix PRO: Fixed an issue where Pinterest sharing failed on some hosts
Fix: Post immediately feature not working in Gutenberg
Change: Moved post immediately feature to metabox
Change: Opened up easier Twitter login workflow for old installs
Change: Sharing as an article post to Facebook no longer requires varifying domain with Facebook Business Manager
Change: Scrape post details before sharing to Facebook to ensure link preview is always up to date
Change: Enhance tutorial pointers
Change: Plugin Roadmap link added to submenu (Vote for features you want to see in ROP!)
Info: Tested on WP 5.3
  • Loading branch information
UVLabs authored Nov 21, 2019
2 parents 9275e9f + a2ec6ba commit a918d1f
Show file tree
Hide file tree
Showing 36 changed files with 2,571 additions and 906 deletions.
6 changes: 6 additions & 0 deletions assets/css/rop.css
Original file line number Diff line number Diff line change
Expand Up @@ -4362,3 +4362,9 @@ padding: 0 20px;
.rop-spacer{
margin: 5px;
}


.tile-action div {
display: inline-block;
vertical-align: middle;
}
406 changes: 279 additions & 127 deletions assets/js/build/dashboard.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions assets/js/build/dashboard.min.js

Large diffs are not rendered by default.

30 changes: 19 additions & 11 deletions assets/js/build/exclude.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/build/exclude.min.js

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions assets/js/build/publish_now.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,9 @@ exports.default = new _vuex2.default.Store({
apiNotAvailable: function apiNotAvailable(state, data) {
state.api_not_available = data;
},
preloading_change: function preloading_change(state, data) {
state.hide_preloading = data;
},
updateState: function updateState(state, _ref) {
var stateData = _ref.stateData,
requestName = _ref.requestName;
Expand Down Expand Up @@ -960,6 +963,11 @@ exports.default = new _vuex2.default.Store({
commit('apiNotAvailable', true);

_vue2.default.$log.error('Error when trying to do request: ', data.req);
}).catch(function (error) {
commit('setAjaxState', false);
commit('apiNotAvailable', true);
commit('preloading_change', 1);
_vue2.default.$log.error('Error when getting response for: ', data.req, error);
});
});
}
Expand Down Expand Up @@ -3762,7 +3770,7 @@ if (false) {(function () { module.hot.accept()
var hotAPI = require("vue-hot-reload-api")
hotAPI.install(require("vue"), true)
if (!hotAPI.compatible) return
var id = "/home/uriahsvictor/atom/git_repos/tweet-old-post/vue/src/vue-elements/pro/publish-now.vue"
var id = "/Users/mihaiirodiu/Local Sites/revivesocialpantheon/app/public/wp-content/plugins/tweet-old-post/vue/src/vue-elements/pro/publish-now.vue"
if (!module.hot.data) {
hotAPI.createRecord(id, module.exports)
} else {
Expand All @@ -3787,8 +3795,8 @@ if(content.locals) module.exports = content.locals;
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-rewriter.js?id=_v-f4350914&file=publish-now.vue!../../../../node_modules/vue-loader/lib/selector.js?type=style&index=0!../../../../node_modules/eslint-loader/index.js!../../../../node_modules/eslint-loader/index.js!./publish-now.vue", function() {
var newContent = require("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-rewriter.js?id=_v-f4350914&file=publish-now.vue!../../../../node_modules/vue-loader/lib/selector.js?type=style&index=0!../../../../node_modules/eslint-loader/index.js!../../../../node_modules/eslint-loader/index.js!./publish-now.vue");
module.hot.accept("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-rewriter.js?id=_v-310ba5ec&file=publish-now.vue!../../../../node_modules/vue-loader/lib/selector.js?type=style&index=0!../../../../node_modules/eslint-loader/index.js!../../../../node_modules/eslint-loader/index.js!./publish-now.vue", function() {
var newContent = require("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-rewriter.js?id=_v-310ba5ec&file=publish-now.vue!../../../../node_modules/vue-loader/lib/selector.js?type=style&index=0!../../../../node_modules/eslint-loader/index.js!../../../../node_modules/eslint-loader/index.js!./publish-now.vue");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
Expand Down Expand Up @@ -15907,7 +15915,7 @@ if (false) {(function () { module.hot.accept()
var hotAPI = require("vue-hot-reload-api")
hotAPI.install(require("vue"), true)
if (!hotAPI.compatible) return
var id = "/home/uriahsvictor/atom/git_repos/tweet-old-post/vue/src/vue-elements/reusables/button-checkbox.vue"
var id = "/Users/mihaiirodiu/Local Sites/revivesocialpantheon/app/public/wp-content/plugins/tweet-old-post/vue/src/vue-elements/reusables/button-checkbox.vue"
if (!module.hot.data) {
hotAPI.createRecord(id, module.exports)
} else {
Expand All @@ -15932,8 +15940,8 @@ if(content.locals) module.exports = content.locals;
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-rewriter.js?id=_v-1bfc9917&file=button-checkbox.vue&scoped=true!../../../../node_modules/vue-loader/lib/selector.js?type=style&index=0!../../../../node_modules/eslint-loader/index.js!../../../../node_modules/eslint-loader/index.js!./button-checkbox.vue", function() {
var newContent = require("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-rewriter.js?id=_v-1bfc9917&file=button-checkbox.vue&scoped=true!../../../../node_modules/vue-loader/lib/selector.js?type=style&index=0!../../../../node_modules/eslint-loader/index.js!../../../../node_modules/eslint-loader/index.js!./button-checkbox.vue");
module.hot.accept("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-rewriter.js?id=_v-933eafe6&file=button-checkbox.vue&scoped=true!../../../../node_modules/vue-loader/lib/selector.js?type=style&index=0!../../../../node_modules/eslint-loader/index.js!../../../../node_modules/eslint-loader/index.js!./button-checkbox.vue", function() {
var newContent = require("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-rewriter.js?id=_v-933eafe6&file=button-checkbox.vue&scoped=true!../../../../node_modules/vue-loader/lib/selector.js?type=style&index=0!../../../../node_modules/eslint-loader/index.js!../../../../node_modules/eslint-loader/index.js!./button-checkbox.vue");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
Expand All @@ -15952,7 +15960,7 @@ exports = module.exports = __webpack_require__(1)();


// module
exports.push([module.i, "\n\t#rop_core .input-group .input-group-addon.btn.active[_v-1bfc9917] {\n\t\tbackground-color: #8bc34a;\n\t\tborder-color: #33691e;\n\t\tcolor: #FFF;\n\t}\n", ""]);
exports.push([module.i, "\n\t#rop_core .input-group .input-group-addon.btn.active[_v-933eafe6] {\n\t\tbackground-color: #8bc34a;\n\t\tborder-color: #33691e;\n\t\tcolor: #FFF;\n\t}\n", ""]);

// exports

Expand Down Expand Up @@ -16039,7 +16047,7 @@ module.exports = {
/***/ 76:
/***/ (function(module, exports) {

module.exports = "\n\t<button class=\"btn input-group-addon column\" :class=\"is_active\" @click=\"toggleThis()\" _v-1bfc9917=\"\">{{label}}</button>\n";
module.exports = "\n\t<button class=\"btn input-group-addon column\" :class=\"is_active\" @click=\"toggleThis()\" _v-933eafe6=\"\">{{label}}</button>\n";

/***/ }),

Expand Down
2 changes: 1 addition & 1 deletion assets/js/build/publish_now.min.js

Large diffs are not rendered by default.

138 changes: 104 additions & 34 deletions includes/admin/abstract/class-rop-services-abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function authorize() {
$authenticated = $this->maybe_authenticate();

if ( $authenticated ) {
$service = $this->get_service();
$service = $this->get_service();
/**
* For LinkedIn, it seems they include '_' char into the service id and
* we need to replace with something else in order to not mess with the way we store the indices.
Expand Down Expand Up @@ -423,6 +423,7 @@ protected function get_legacy_url( $network = '' ) {
protected function normalize_string( $string ) {
return preg_replace( '/[[:^print:]]/', '', $string );
}

/**
* Strip underscore and replace with safe char.
*
Expand All @@ -433,6 +434,7 @@ protected function normalize_string( $string ) {
protected function strip_underscore( $name ) {
return str_replace( '_', '---', $name );
}

/**
* Adds back the underscore.
*
Expand All @@ -453,6 +455,7 @@ protected function unstrip_underscore( $name ) {
*/
protected function strip_whitespace( $data ) {
$data = rtrim( ltrim( $data ) );

return $data;
}

Expand All @@ -465,6 +468,7 @@ protected function strip_whitespace( $data ) {
*/
protected function strip_excess_blank_lines( $content ) {
$content = preg_replace( "/([\r\n]{4,}|[\n]{3,}|[\r]{3,})/", "\n\n", $content );

return $content;
}

Expand All @@ -486,53 +490,59 @@ protected function rop_get_error_docs( $response ) {

$errors_docs = array(
// Facebook errors
'Only owners of the URL have the ability' => array(
'Only owners of the URL have the ability' => array(
'message' => __( 'You need to verify your website with Facebook before sharing posts as article posts.', 'tweet-old-post' ),
'link' => 'https://is.gd/fix_owners_url',
'link' => 'https://is.gd/fix_owners_url',
),
'manage_pages and publish_pages as an admin' => array(
'manage_pages and publish_pages as an admin' => array(
'message' => __( 'You need to put your Facebook app through review.', 'tweet-old-post' ),
'link' => 'https://is.gd/fix_manage_pages_error',
'link' => 'https://is.gd/fix_manage_pages_error',
),
'Invalid parameter' => array(
'Invalid parameter' => array(
'message' => 'There might be an issue with link creations on your website.',
'link' => 'https://is.gd/fix_link_issue',
'link' => 'https://is.gd/fix_link_issue',
),

// Twitter errors
'Desktop applications only support the oauth_callback value' => array(
'message' => 'Your Callback URL for your Twitter app might not be correct.',
'link' => 'https://is.gd/fix_oauth_callback_value',
'link' => 'https://is.gd/fix_oauth_callback_value',
),
'User is over daily status update limit' => array(
'User is over daily status update limit' => array(
'message' => 'You might be over your daily limit for sending tweets or our app has hit a limit.',
'link' => 'https://is.gd/fix_over_daily_limit',
'link' => 'https://is.gd/fix_over_daily_limit',
),
'Invalid media_id: Some' => array(
'Invalid media_id: Some' => array(
'message' => 'Our plugin might be having an issue posting tweets with an image to your account.',
'link' => 'https://is.gd/fix_invalid_media',
'link' => 'https://is.gd/fix_invalid_media',
),
'Callback URL not approved for this client application' => array(
'message' => 'Your Callback URL for your Twitter app might not be correct.',
'link' => 'https://is.gd/fix_oauth_callback_value',
'link' => 'https://is.gd/fix_oauth_callback_value',
),

// LinkedIn errors
'&#39;submitted-url&#39; can not be empty' => array(
'&#39;submitted-url&#39; can not be empty' => array(
'message' => 'There might be an issue with link creations on your website.',
'link' => 'https://is.gd/fix_link_issue',
'link' => 'https://is.gd/fix_link_issue',
),

// Pinterest errors
'Pinterest error (code: 429) with message: You have exceeded your rate limit' => array(
'message' => 'You\'ve hit the Pinterest rate limit.',
'link' => 'https://is.gd/pinterest_rate_limit',
),

// Add more common errors as necessary
);

$message = '';
$link = '';
$link = '';

foreach ( $errors_docs as $error => $data ) {
if ( strpos( $response, $error ) !== false ) {
$message = $data['message'];
$link = $data['link'];
$link = $data['link'];
break;
}
}
Expand All @@ -541,7 +551,7 @@ protected function rop_get_error_docs( $response ) {
return;
}

$known_error = __( 'This error is a known one. ', 'tweet-old-post' );
$known_error = __( 'This error is a known one. ', 'tweet-old-post' );
$instructions = __( 'Please copy and paste the following link in your browser to see the solution: ', 'tweet-old-post' );

return $this->logger->alert_error( $known_error . $message . $instructions . $link );
Expand All @@ -554,23 +564,28 @@ protected function rop_get_error_docs( $response ) {
* Used where file_get_contents might not work with urls, we provide the file path.
*
* @param string $image_url Image url.
* @param array $mimetype Used to identify the mime type.
*
* @return string Image path.
*/
protected function get_path_by_url( $image_url, $mimetype ) {

$dir = wp_upload_dir();
protected function get_path_by_url( $image_url, $mimetype = array() ) {
if ( empty( $image_url ) ) {
return '';
}

// Upload folder.
$dir = wp_upload_dir();
$parsed = parse_url( $dir['baseurl'] );

$dir = $parsed['host'] . $parsed['path'];
$dir = $parsed['host'] . $parsed['path'];

if ( false === strpos( $image_url, $dir ) ) {
return $image_url;
}
// Fetch the filename.
$file = wp_basename( $image_url );

$file = basename( $image_url );
$query = array(
// Find the media ID in the database using the filename.
$query = array(
'post_type' => 'attachment',
'fields' => 'ids',
'posts_per_page' => '20',
Expand All @@ -583,25 +598,37 @@ protected function get_path_by_url( $image_url, $mimetype ) {
),
),
);

$ids = get_posts( $query );
$id_found = false;

// If the attachment is not an image, return the url.
if ( strpos( $mimetype['type'], 'video' ) !== false ) {
if ( empty( $ids ) ) {
return $image_url;
}

return get_attached_file( reset( $ids ) );
$reset_id_list = reset( $ids );

return get_attached_file( $reset_id_list );
}
if ( ! empty( $ids ) ) {

if ( ! empty( $ids ) ) {
foreach ( $ids as $id ) {
if ( $image_url === array_shift( wp_get_attachment_image_src( $id, 'full' ) ) ) {
$image_get = wp_get_attachment_image_src( $id, 'full' );
$attachment_url = array_shift( $image_get );
$attachment_image_name = wp_basename( $attachment_url ); // get filename from URL.
$image_url_name = wp_basename( $image_url ); // get filename from URL.
// Check if the found image is the one we require.
if ( $image_url_name === $attachment_image_name ) {
$id_found = $id;
break;
}
}
}
if ( $id_found === false ) {

// If the image is a WP size instead of full.
if ( false === $id_found ) {
$query['meta_query'][0]['key'] = '_wp_attachment_metadata';

// query attachments again
Expand All @@ -614,22 +641,23 @@ protected function get_path_by_url( $image_url, $mimetype ) {
foreach ( $ids as $id ) {

$meta = wp_get_attachment_metadata( $id );

// Check which of the size value is the requested one.
foreach ( $meta['sizes'] as $size => $values ) {

if ( $values['file'] === $file && $image_url === array_shift( wp_get_attachment_image_src( $id, $size ) ) ) {
if ( $values['file'] === $file ) { // compare filenames.
$id_found = $id;
break;
}
}
if ( $id_found === false ) {
if ( false === $id_found ) {
break;
}
}
}
if ( $id_found === false ) {

if ( false === $id_found ) {
return $image_url;
}

$path = get_attached_file( $id_found );
if ( empty( $path ) ) {
return $image_url;
Expand All @@ -638,5 +666,47 @@ protected function get_path_by_url( $image_url, $mimetype ) {
return $path;
}

/**
* Converts image into base_64 code from given local path
*
* @since 8.5.0
*
* @param string $image_path - Full local image path to uploads folder.
*
* @return string
*/
protected function convert_image_to_base64( $image_path = '' ) {
$opened_file = fopen( $image_path, 'r' );
if ( false === $opened_file ) { // If the file cannot be opened, we need to return the given path instead.
return $image_path;
}

$contents = fread( $opened_file, filesize( $image_path ) );
fclose( $opened_file );

return base64_encode( $contents );
}

/**
* Checks to see if the cURL library is loaded and the function can be found.
*
* @return bool true/false if function is found.
* @since 8.5.0
*/
protected function is_curl_active() {
return function_exists( 'curl_init' );
}

/**
* Returns true if the string $file_path is an URL.
*
* @param string $file_path string with filepath or url.
*
* @since 8.5.0
*
* @return boolean
*/
protected function is_remote_file( $file_path = '' ) {
return preg_match( '/^(https?|ftp):\/\/.*/', $file_path ) === 1;
}
}
Loading

0 comments on commit a918d1f

Please sign in to comment.