PluginProbe
Document Embedder – let visitors read files without downloading / 1.0
Document Embedder – let visitors read files without downloading v1.0
2.3.1 2.3.0 2.2.1 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.3 1.7.4 1.7.6 1.7.9 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 2.0.0 2.0.1 2.0.2 All 30 releases
document-emberdder / document-embedder.php

document-embedder.php in Document Embedder – let visitors read files without downloading 1.0, at document-embedder.php

301 lines 11.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Plugin Name: Document Embedder
4 * Plugin URI: https://1infosoft.com/coming-soon
5 * Description: Embed Any document easily in wordpress such as word, excel, powerpoint, pdf and more
6 * Version: 1.0
7 * Author: Abu Hayat Polash
8 * Author URI: http://abuhayatpolash.com
9 * License: GPLv3
10 */
11
12 /*Some Set-up*/
13 define('PPV_PLUGIN_DIR', WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/' );
14
15
16
17 //Remove post update massage and link
18 function ppv_updated_messages( $messages ) {
19 $messages['ppt_viewer'][1] = __('Updated ');
20 return $messages;
21 }
22 add_filter('post_updated_messages','ppv_updated_messages');
23
24
25
26 /*-------------------------------------------------------------------------------*/
27 /* Register Custom Post Types
28 /*-------------------------------------------------------------------------------*/
29 add_action( 'init', 'ppv_create_post_type' );
30 function ppv_create_post_type() {
31 register_post_type( 'ppt_viewer',
32 array(
33 'labels' => array(
34 'name' => __( 'Document Embedder'),
35 'singular_name' => __( 'Document Embedder' ),
36 'add_new' => __( 'Add New Doc' ),
37 'add_new_item' => __( 'Add New Doc' ),
38 'edit_item' => __( 'Edit' ),
39 'new_item' => __( 'New item' ),
40 'view_item' => __( 'View item' ),
41 'search_items' => __( 'Search'),
42 'not_found' => __( 'Sorry, we couldn\'t find the power point file you are looking for.' )
43 ),
44 'public' => false,
45 'show_ui' => true,
46 'publicly_queryable' => true,
47 'exclude_from_search' => true,
48 'menu_position' => 14,
49 'menu_icon' =>PPV_PLUGIN_DIR .'/img/doc.png',
50 'has_archive' => false,
51 'hierarchical' => false,
52 'capability_type' => 'post',
53 'rewrite' => array( 'slug' => 'ppt_viewer' ),
54 'supports' => array( 'title' )
55 )
56 );
57 }
58
59 /*-------------------------------------------------------------------------------*/
60 /* Metabox
61 /*-------------------------------------------------------------------------------*/
62
63 include_once('metabox/meta-box-class/my-meta-box-class.php');
64 include_once('metabox/class-usage-demo.php');
65 //include_once('tinymce/ewic-tinymce.php');
66
67 /*-------------------------------------------------------------------------------*/
68 /* Hide & Disabled View, Quick Edit and Preview Button
69 /*-------------------------------------------------------------------------------*/
70 function ppv_remove_row_actions( $idtions ) {
71 global $post;
72 if( $post->post_type == 'ppt_viewer' ) {
73 unset( $idtions['view'] );
74 unset( $idtions['inline hide-if-no-js'] );
75 }
76 return $idtions;
77 }
78
79 if ( is_admin() ) {
80 add_filter( 'post_row_actions','ppv_remove_row_actions', 10, 2 );}
81
82 /*-------------------------------------------------------------------------------*/
83 /* HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button
84 /*-------------------------------------------------------------------------------*/
85
86 function ppv_hide_publishing_actions(){
87 $my_post_type = 'ppt_viewer';
88 global $post;
89 if($post->post_type == $my_post_type){
90 echo '
91 <style type="text/css">
92 #misc-publishing-actions,
93 #minor-publishing-actions{
94 display:none;
95 }
96 </style>
97 ';
98 }
99 }
100 add_action('admin_head-post.php', 'ppv_hide_publishing_actions');
101 add_action('admin_head-post-new.php', 'ppv_hide_publishing_actions');
102
103 /*-------------------------------------------------------------------------------*/
104 /* Change publish button to save.
105 /*-------------------------------------------------------------------------------*/
106
107 add_filter( 'gettext', 'ppv_change_publish_button', 10, 2 );
108
109 function ppv_change_publish_button( $translation, $text ) {
110 if ( 'ppt_viewer' == get_post_type())
111 if ( $text == 'Publish' )
112 return 'Save';
113
114 return $translation;
115 }
116
117
118 // ONLY MOVIE CUSTOM TYPE POSTS
119 add_filter('manage_ppt_viewer_posts_columns', 'ST4_columns_head_only_ppt_viewer', 10);
120 add_action('manage_ppt_viewer_posts_custom_column', 'ST4_columns_content_only_ppt_viewer', 10, 2);
121
122 // CREATE TWO FUNCTIONS TO HANDLE THE COLUMN
123 function ST4_columns_head_only_ppt_viewer($defaults) {
124 $defaults['directors_name'] = 'ShortCode';
125 return $defaults;
126 }
127 function ST4_columns_content_only_ppt_viewer($column_name, $post_ID) {
128 if ($column_name == 'directors_name') {
129 // show content of 'directors_name' column
130 echo '<input onClick="this.select();" value="[doc id='. $post_ID . ']" >';
131 }
132 }
133
134 /*-------------------------------------------------------------------------------*/
135 // sub menu page
136 /*-------------------------------------------------------------------------------*/
137 add_action('admin_menu', 'ppv_custom_submenu_page');
138
139 function ppv_custom_submenu_page() {
140 add_submenu_page( 'edit.php?post_type=ppt_viewer', 'Developer', 'Developer', 'manage_options', 'ppv_submenu_page', 'ppv_submenu_page_callback' );
141 }
142
143 function ppv_submenu_page_callback() {
144
145 echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
146 echo '<h2>Developer</h2>
147 <h2>Md Abu hayat polash</h2>
148 <h4>Professional Web Developer (Freelancer)</h4>
149 <h5>Web : <a href="http://abuhayatpolash.com">www.abuhayatpolash.com</h5></a>
150 <h5>Hire Me : <a href="http://fiverr.com/abuhayat">www.fiverr.com/abuhayat</h5></a>
151 Email: <a href="mailto:abuhayat.du@gmail.com">abuhayat.du@gmail.com </a>
152 <h5>Skype: ah_polash</h5>
153 <br />
154
155 ';
156 echo '</div>';
157
158 }
159 //How to use
160 add_action('admin_menu', 'svp_howto_page');
161
162 function svp_howto_page() {
163 add_submenu_page( 'edit.php?post_type=ppt_viewer', 'How To Use', 'How To Use', 'manage_options', 'ppv_howto', 'ppv_howto_page_callback' );
164 }
165
166 function ppv_howto_page_callback() {
167
168 echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
169 echo '<h2>How to use </h2>
170 <h2>Watch the video to learn how to use the plugin. </h2>
171 <br/>
172 Coming Soon...
173 <br />
174
175 ';
176 echo '</div>';
177
178 }
179
180 /*
181 <iframe width="789" height="375" src="https://www.youtube.com/embed/LJym2Pe1h2k" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
182 */
183
184
185 /*-------------------------------------------------------------------------------*/
186 // Dashboard widget
187 /*-------------------------------------------------------------------------------*/
188
189
190 function ppv_add_dashboard_widgets() {
191 wp_add_dashboard_widget( 'ppv_example_dashboard_widget', 'Support Document Embedder', 'ppv_dashboard_widget_function' );
192
193 global $wp_meta_boxes;
194 $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
195 $example_widget_backup = array( 'ppv_example_dashboard_widget' => $normal_dashboard['ppv_example_dashboard_widget'] );
196 unset( $normal_dashboard['ppv_example_dashboard_widget'] );
197 $sorted_dashboard = array_merge( $example_widget_backup, $normal_dashboard );
198 $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
199 }
200 function ppv_dashboard_widget_function() {
201
202 // Display whatever it is you want to show.
203 echo '
204 <p>It is hard to continue development and support for this plugin without contributions from users like you. If you enjoy using the plugin and find it useful, please consider support by <b>DONATION</b> or <b>BUY THE PRO VERSION (Ad Less)</b> of the Plugin. Your support will help encourage and support the plugin’s continued development and better user support.</p>
205 <center>
206 <a target="_blank" href="https://gum.co/wpdonate"><div><img width="200" src="'.PPV_PLUGIN_DIR.'img/donation.png'.'" alt="Donate Now" /></div></a>
207 </center>
208 <br />
209
210
211
212 ';}
213 add_action( 'wp_dashboard_setup', 'ppv_add_dashboard_widgets' );
214
215
216 // Adds a box to the main column on the Post and Page edit screens.
217
218 function ppv_myplugin_add_meta_box() {
219 add_meta_box(
220 'donation',
221 __( 'Support Document Embedder', 'myplugin_textdomain' ),
222 'ppv_callback_donation',
223 'ppt_viewer'
224 );
225 add_meta_box(
226 'myplugin_sectionid',
227 __( 'Try LightBox Addons', 'myplugin_textdomain' ),
228 'ppv_addons_callback',
229 'ppt_viewer',
230 'side'
231 );
232 add_meta_box(
233 'myplugin',
234 __( 'Please show some love', 'myplugin_textdomain' ),
235 'ppv_callback',
236 'ppt_viewer',
237 'side'
238 );
239 }
240 add_action( 'add_meta_boxes', 'ppv_myplugin_add_meta_box' );
241 function ppv_callback_donation( ) {echo 'If you found this Plugin helpful and wish to support our opensource Project, Then You can <a target="_blank" href="https://gum.co/wpdonate">DONATE</a> us any amount you want. <a target="_blank" href="https://gum.co/wpdonate">Donate Now</a>';};
242 function ppv_addons_callback(){echo'<a target="_blank" href="http://bit.ly/2GiuI2G"><img style="width:100%" src="'.PPV_PLUGIN_DIR.'/img/upwork.png" ></a>
243 <p>LightBox Addons enable you to open any doc in a Nice LightBox</p>
244 <table>
245 <tr>
246 <td><a class="button button-primary button-large" href="http://bit.ly/2XlTTIy" target="_blank">See Demo </a></td>
247 <td><a class="button button-primary button-large" href="http://bit.ly/2GiuI2G" target="_blank">Buy Now</a></td>
248 </tr>
249 </table>
250 ';};
251
252 function ppv_callback( ) {echo 'If you like <strong>Document Embedder </strong> Plugin, please leave us a <a href="https://wordpress.org/support/plugin/document-emberdder/reviews/?filter=5#new-post" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733; rating.</a> Your Review is very important to us as it helps us to grow more.
253 <p>Need some improvement ? <a href="mailto:abuhayat.du@gmail.com">Please let me know </a> how can i improve the Plugin.</p>';};
254
255
256 // Add Sortcode
257 function ppv_cpt_content_func($atts){
258 extract( shortcode_atts( array(
259
260 'id' => null,
261
262 ), $atts ) );
263
264 $file_url=get_post_meta($id,'_groupped_ppv_file_url', true);
265 $ext_url=get_post_meta($id,'_groupped_ppv_ext_url', true);
266 if (is_array($file_url)){$url=$file_url['url'];}else{$url=$ext_url;}
267
268 $width=get_post_meta($id,'ppt_ppv_width', true);
269 $height= get_post_meta($id,'ppt_ppv_height', true);
270
271 if ($width==''){$width='100%';} else{$width=$width.'px';}
272 if ($height==''){$height='600px'; } else {$height=$height.'px';}
273 $frame_style= 'width:'.$width.'; '. 'height:'. $height. ';';
274
275 $viewer_type=get_post_meta($id,'ppt_ppv_type', true);
276
277 if($viewer_type == 'googledocs'){
278 $base_url = 'https://docs.google.com/gview?embedded=true&url=';
279 }else{
280 $base_url = 'https://view.officeapps.live.com/op/embed.aspx?src=';
281 }
282
283 if($url==''){ echo '<h2>Ooops... You forgot to Select a document. Please select a file or paste a external document link to show here. </h2>';} else{
284 // show file name
285 $file_name=get_post_meta($id,'ppt_ppv_file_name', true);
286 if($file_name=='on'){$file_name=basename($url); echo '<br/>File Name: '.$file_name.'<br/>';}
287
288 // Download button
289 if(get_post_meta($id,'ppt_ppv_download',true)=='on'){
290 $down_btn_color= get_post_meta($id,'ppt_ppv_download_btn_color', true);
291 echo '<p><a class="s_pdf_download_link" href="'.$url.'" download><button style="'.'background-color:'.$down_btn_color.';" class="ppv_download_bttn">'.get_post_meta($id,'ppt_ppv_download_btn_text',true).'</button></a></p>';}
292
293
294
295
296
297 echo '<iframe id="s_pdf_frame" src="' . $base_url . $url . '" style="float:left;' . $frame_style . '" frameborder="0"></iframe>';
298 }
299
300 }
301 add_shortcode('doc','ppv_cpt_content_func');