Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Google Docs Embed
- Plugin URI: http://en.bainternet.info
- Description: Simple plugin that provides a shortcode to embed PDF ,Word document or PowerPoint presentation.
- Version: 1.0
- Author: Bainternet
- Author URI: http://en.bainternet.info
- */
- /*
- * Copyright (C) 2011 Ohad Raz
- * http://en.bainternet.info
- * admin@bainternet.info
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
- /* Disallow direct access to the plugin file */
- if (basename($_SERVER['PHP_SELF']) == basename (__FILE__)) {
- //die('Sorry, but you cannot access this page directly.');
- }
- add_shortcode('GDOCS', 'Gdocs_embed');
- function Gdocs_embed( $atts, $content = null ) {
- extract( shortcode_atts( array(
- 'height' => 300,
- 'width' => 400,
- 'style' => '',
- 'title' => '',
- 'class' => 'pdf',
- 'id' => '',
- 'url' => ''
- ), $atts ) );
- if (!strstr($url,'http://')) {
- return '';
- }
- $embed = '<iframe src="http://docs.google.com/viewer?url='.urlencode($url).'&embedded=true" style="height:'.$height.'px;width:'.$width.'px;" class="'.$class.'"';
- if ($id != '') {
- $embed .= ' id="'.$id.'"';
- }
- if ($style != '') {
- $embed .= ' style="'.$style.'"';
- }
- if ($title != '') {
- $embed .= ' title="'.$title.'"';
- }
- $embed .= '></iframe>';
- return apply_filters( 'GDOCS', $embed );
- }
- /*
- Usage:
- [GDOCS url="http://link.to/PDF"]
- */
Add Comment
Please, Sign In to add comment