Changeset 2724665
- Timestamp:
- 05/16/2022 03:03:40 PM (4 years ago)
- Location:
- makestories-helper/trunk
- Files:
-
- 1 deleted
- 2 edited
-
api/publish.php (modified) (1 diff)
-
helpers.php (modified) (1 diff)
-
templates/editor-full.php (deleted)
Legend:
- Unmodified
- Added
- Removed
-
makestories-helper/trunk/api/publish.php
r2724522 r2724665 155 155 ]); 156 156 wp_die(); 157 // $replaced = false;158 // if(159 // isset($_REQUEST['imageurl']) &&160 // isset($_REQUEST['post_id'])161 // ){162 // $imageurl = $_REQUEST['imageurl'];163 // $atta_title = basename( $imageurl );164 //165 // if(isset($_REQUEST['atta_title'])){166 // $atta_title = $_REQUEST['atta_title'];167 // }168 //169 // if(isset($_REQUEST['filename'])){170 // $filename = $_REQUEST['filename'];171 // }else{172 // $name = $imageurl;173 // $nameExploded = explode("?",$imageurl);174 // if(count($nameExploded)){175 // $nameExploded = $nameExploded[0];176 // }177 // $nameExploded = explode("/",$nameExploded);178 // if(count($nameExploded)){179 // $name = $nameExploded[count($nameExploded) - 1];180 // }181 // $filename = date('dmY').''.(int) microtime(true).basename($name);182 // }183 //184 // $postId = $_REQUEST['post_id'];185 // include_once( ABSPATH . 'wp-admin/includes/image.php' );186 // if( ! ( function_exists( 'wp_get_attachment_by_post_name' ) ) ) {187 // function wp_get_attachment_by_post_name( $post_name ) {188 // $id = post_exists($post_name);189 // $args = array(190 // 'posts_per_page' => 1,191 // 'post_type' => 'attachment',192 // 'p' => $id,193 // );194 //195 // $get_attachment = new WP_Query( $args );196 //197 // if ( ! $get_attachment || ! isset( $get_attachment->posts, $get_attachment->posts[0] ) ) {198 // return false;199 // }200 //201 // return $get_attachment->posts[0];202 // }203 // }204 //205 // $attach_id = false;206 // $forceUploadMedia = ms_get_options()['forceUploadMedia'];207 // if(wp_validate_boolean(apply_filters("ms_check_for_duplicate_media", true))){208 // $getAttachment = wp_get_attachment_by_post_name( $atta_title );209 // }210 // if(isset($_REQUEST['is_republish']) && wp_validate_boolean($_REQUEST['is_republish'])){211 // $forceUploadMedia = true;212 // }213 // if( post_exists($atta_title) && !$forceUploadMedia && $getAttachment) {214 // $attach_id = $getAttachment->ID;215 // }216 // else{217 //218 // $wp_filetype = wp_check_filetype(basename($filename), null );219 // if(empty($wp_filetype['type'])){220 // $wp_filetype = ms_find_filetype($imageurl);221 // }222 //223 // if(isset($wp_filetype['ext']) && !empty($wp_filetype['ext']) && !msEndsWith($filename, $wp_filetype['ext'])){224 // $filename = $filename.".".$wp_filetype['ext'];225 // }226 //227 // $uploaddir = wp_upload_dir();228 // $uploadfile = $uploaddir['path'] . '/' . $filename;229 // $contents= file_get_contents($imageurl);230 // $savefile = fopen($uploadfile, 'w');231 // fwrite($savefile, $contents);232 // fclose($savefile);233 //234 // $attachment = array(235 // 'post_mime_type' => $wp_filetype['type'],236 // 'post_title' => $atta_title,237 // 'post_content' => '',238 // 'post_status' => 'inherit',239 // );240 // $attach_id = wp_insert_attachment( $attachment, $uploadfile );241 // if($attach_id){242 // $attach_data = wp_generate_attachment_metadata($attach_id, $uploadfile);243 // wp_update_attachment_metadata($attach_id, $attach_data);244 // }245 // }246 //247 // if($attach_id){248 // // Get permalink of media library249 // $permalink = wp_get_attachment_url($attach_id);250 // $post = get_post($postId);251 // $html = $post->post_content;252 // // Replace permalink of image with html253 // $html = str_ireplace($imageurl, $permalink, $html);254 // $replaced = true;255 // $updated = wp_update_post([256 // "post_content" => $html,257 // "ID" => $postId,258 // ]);259 //260 // //CHeck in post meta data261 // $meta = get_post_meta($postId, "publisher_details", true);262 // try{263 // $meta = json_decode($meta, true);264 // $propertiesToAdd = [265 // "publisher-logo-src",266 // "poster-portrait-src",267 // "poster-landscape-src",268 // "poster-square-src",269 // ];270 // foreach ($propertiesToAdd as $prop){271 // if(isset($meta[$prop]) && $meta[$prop] == $imageurl){272 // $meta[$prop] = $permalink;273 // }274 // }275 // update_post_meta( $postId, "publisher_details", json_encode($meta));276 // }catch(Exception $e){277 // //Do Nothing278 // }279 //280 // }281 // }282 // echo json_encode([283 // "replaced" => $replaced,284 // ]);285 // wp_die();286 157 } 287 158 -
makestories-helper/trunk/helpers.php
r2724522 r2724665 17 17 */ 18 18 function ms_get_story_HTML($storyId){ 19 $c = curl_init(MS_PREVIEW_URL.$storyId.'?forWordpress&v=2'); 20 curl_setopt($c, CURLOPT_RETURNTRANSFER, true); 21 curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); 22 23 $html = curl_exec($c); 24 25 if ($e = curl_error($c)){ 26 die(json_encode(["success" => false, "error" => "Error occurred while fetching story data.", "message" => $e])); 27 } 28 // Get the status code 29 curl_close($c); 19 $url = MS_PREVIEW_URL.$storyId.'?forWordpress&v=2'; 20 $response = wp_remote_get($url); 21 $html = $response['body']; 30 22 return $html; 31 }32 33 /**34 * Function to get MIMETYPE of URL35 * @param $imageurl string36 * @return bool|string37 */38 function ms_find_filetype($imageurl){39 $c = curl_init(MS_BASE_SERVER_URL.'get-image-meta?url='.urlencode($imageurl));40 curl_setopt($c, CURLOPT_RETURNTRANSFER, true);41 42 $details = curl_exec($c);43 44 if (curl_error($c)){45 die(json_encode(["success" => false, "error" => "Error occurred while fetching image type."]));46 }47 // Get the status code48 curl_close($c);49 $details = json_decode($details, true);50 23 } 51 24
Note: See TracChangeset
for help on using the changeset viewer.