Slider and gallery wp

OUT DATED POST

I needed a Slider and gallery of images using WordPress as it is my preferred development CMS because WordPress is very popular all over the world for several reasons. It’s easy to manage in beginner level, there is a lot of documentation and there is a huge community supporting new comers, but for more information you can check here or do your own research in Google. Continue reading

Read the content of a word document with PHP.

Today we will try to read a word document with PHP, and when I say read I mean take the text in the document and extract it.

First we create this function:

<?php
    function read_file_docx($filename){

        $striped_content = '';
        $content = '';

        if(!$filename || !file_exists($filename)) return false;

        $zip = zip_open($filename);

        if (!$zip || is_numeric($zip)) return false;

        while ($zip_entry = zip_read($zip)) {

            if (zip_entry_open($zip, $zip_entry) == FALSE) continue;

            if (zip_entry_name($zip_entry) != "word/document.xml") continue;

            $content .= zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));

            zip_entry_close($zip_entry);
        }// end while

        zip_close($zip);

        //echo $content;
        //echo "<hr>";
        //file_put_contents('1.xml', $content);        

        $content = str_replace('</w:r></w:p></w:tc><w:tc>', " ", $content);
        $content = str_replace('</w:r></w:p>', "\r\n", $content);
        $striped_content = strip_tags($content);

        return $striped_content;
    }

?>

Second we use the function:

<?php
$filename = "file.docx";
// or /var/www/html/file.docx
 $content = read_file_docx($filename);
 if($content !== false) {        print_r(nl2br($content));    }    
else {        echo 'Couldn\'t the file. Please check that file.';    }
?>

This is able to read a MS word for instance this document:

Screenshot from 2013-08-12 15:58:27

Is read as:

Screenshot from 2013-08-12 16:04:00

As you may see PHP is able to read the content, of course there are some characters that PHP interprets differently from MS word, but maybe working with this as an input you can get what you want as the final result.

Regards

Child Theme WordPress

Well today I’m going to explain how to create a child theme in WordPress is kind of simple work, but some of us had to struggle to get it done when we started to do our first WordPress sites (by we you my understand ME), because the true is that is very easy now that I know.

Responsive child theme

Responsive child theme

Basically what you have to do is to go to /wp-content/themes/ create a folder with the name of the child theme (different from other themes you have) for instance “sosolar”. Inside this folder you can create any structure on a theme, but the only file required is “style.css”, then you only have to create a special content for this file.
The file is supposed to have inside the following:

/*
Theme Name: My Child Theme(in this case sosolar)
Theme URI: http: //mysite.com/ (in this case

http://www.abelworld.com/wordpress-child-theme)
Description: This is a custom child theme I have created.
(or put a reference to the description like http://www.abelworld.com/about/ this theme)
Author: My Name (for instance: Abel Guzman Sanchez)
Author URI: http: //mysite.com/ (in this case: https://www.abelworld.com/about/)
Template: parenttheme
(in this case twentytwelve is a nice theme I like it as base to start doing serious things)
Version: Version number (in this case 0.1)
*/

So basically your child theme would be something like:

/*
 Theme Name:     sosolar
 Theme URI:      http://www.abelworld.com/child-theme-wordpress/
 Description:    Child theme for the Twenty eleven theme
 Author:         Abel Guzman
 Author URI:     https://plus.google.com/u/0/116095396075951868976/posts
 Template:       twentyeleven                             Version:        0.1.0
 */
End of the story, of couse this child theme does not do any thing, the rest depends on what do you want to modify. for instance you can check this other example. Otherwise if you want to modify styles you just have to change may by this file you created, and remember that what you do in here overrides what is in the father theme. You might expect  some more posts on this subject on the near future. Enjoy.