From f2ace8db8002963b5313642e66a8c6276c6dec48 Mon Sep 17 00:00:00 2001 From: Orlando Echevarria Date: Tue, 2 Apr 2024 14:42:23 -0400 Subject: [PATCH] Add files via upload --- grandchild-functions.php | 121 ++++++ grandchild-scripts.js | 30 ++ grandchild-styles.css | 805 +++++++++++++++++++++++++++++++++++++++ template-class.php | 221 +++++++++++ 4 files changed, 1177 insertions(+) create mode 100644 grandchild-functions.php create mode 100644 grandchild-scripts.js create mode 100644 grandchild-styles.css create mode 100644 template-class.php diff --git a/grandchild-functions.php b/grandchild-functions.php new file mode 100644 index 0000000..0ab592a --- /dev/null +++ b/grandchild-functions.php @@ -0,0 +1,121 @@ + $word_limit) + array_pop($words); + return implode(' ', $words); +} + +// ------------------------- Custom Header ------------------------- + +// We are hooking to the 'load_custom_header' filter +// and return a value of 'true' meaning that we want to +// load a custom header + +/* + +add_filter( 'load_custom_header', '__return_true', 99 ); + +add_filter( 'get_custom_header', function( $header ) { + return plugin_dir_path( __FILE__ ).'templates/header.php'; +}, 99 ); + +*/ + +// ------------------------- Register a new sidebar ------------------------- + +/* + +if ( function_exists('register_sidebar') ) { + register_sidebar( array( + 'name' => __( 'Header - Social Media' ), + 'id' => 'header-social', + 'description' => __( 'Widgets in this area will be shown on the header.' ), + 'before_title' => '

', + 'after_title' => '

', + ) ); +} + +*/ + +//------------------------- Add templates to post loop drop down ------------------------- + + + +function grandchild_postloop_template_include( $templates ) { + $templates[] = '../../plugins/grandchild-mechanical/templates/content-home-three-grid.php'; + return $templates; + +} + + +add_filter( 'siteorigin_panels_postloop_templates', 'grandchild_postloop_template_include', 11 ); + + + +//------------------------- Custom single.php template ------------------------- + +/* + +add_filter('template_include', 'my_plugin_templates'); +function my_plugin_templates( $template ) { + $post_types = array('post'); + + if (is_singular($post_types)) { + $template = plugin_dir_path( __FILE__ ).'templates/single.php'; + } + + return $template; +} + +*/ + +// ------------------------- Custom Footer ------------------------- + +/* + +add_filter( 'load_custom_footer', '__return_true', 99 ); + +add_filter( 'get_custom_footer', function( $footer ) { + return plugin_dir_path( __FILE__ ).'templates/footer.php'; +}, 99 ); +*/ + +?> \ No newline at end of file diff --git a/grandchild-scripts.js b/grandchild-scripts.js new file mode 100644 index 0000000..0bc88b5 --- /dev/null +++ b/grandchild-scripts.js @@ -0,0 +1,30 @@ +jQuery.noConflict()(function ($) { // this was missing for me + $(document).ready(function() { + function close_accordion_section() { + $('.accordion .accordion-section-title').removeClass('active'); + $('.accordion .accordion-section-content').slideUp(300).removeClass('open'); + } + + $('.accordion-section-title').click(function(e) { + // Grab current anchor value + var currentAttrValue = $(this).attr('href'); + + if($(e.target).is('.active')) { + close_accordion_section(); + } + else if ($(e.target).is('.active img')) { + close_accordion_section(); + } + else { + close_accordion_section(); + + // Add active class to section title + $(this).addClass('active'); + // Open up the hidden content panel + $('.accordion ' + currentAttrValue).slideDown(300).addClass('open'); + } + + e.preventDefault(); + }); + }); +}); \ No newline at end of file diff --git a/grandchild-styles.css b/grandchild-styles.css new file mode 100644 index 0000000..16ce34d --- /dev/null +++ b/grandchild-styles.css @@ -0,0 +1,805 @@ +@import url('https://fonts.googleapis.com/css?family=Roboto+Slab:400,700|Roboto:400,400i,500,500i,700,700i'); + +body { + font-family: 'Roboto'; +} + +h1, h2, h3, h4, h5, h6 { + font-family: 'Roboto Slab'; + font-weight:400; + color:#333; +} + +h1, .h1 { + font-size:35px; + color:#016DC8; /* Blue color */ +} + +h2, .h2 { + font-size: 28px; + color:#CE952E; /* Yellow color */ +} + +h3, .h3 { + font-size:23px; +} + +p { + line-height:1.6em; +} + +a { + color:#0E73CD; + -webkit-transition: background-color 300ms linear; + -moz-transition: background-color 300ms linear; + -o-transition: background-color 300ms linear; + -ms-transition: background-color 300ms linear; + transition: background-color 300ms linear; +} + a:hover { + color:#035FAF; + -webkit-transition: background-color 300ms linear; + -moz-transition: background-color 300ms linear; + -o-transition: background-color 300ms linear; + -ms-transition: background-color 300ms linear; + transition: background-color 300ms linear; + } + +abbr[title], abbr[data-original-title] { /* fix for hover state over date for calendar widget */ + cursor: pointer; +} + +/* ================== Header ==================== */ +#uc-header { + border-bottom-color: rgba(255, 255, 255, 0.07); +} + +#masthead { + background:#081132; +} + #masthead #site-title .searchform fieldset .form-control { + border:1px solid #174f99; + border-right:none; + background-color: transparent; + min-height: 34px; + padding-bottom: 5px; + padding-top: 6px; + } + + #masthead #site-title .searchform fieldset .btn { + border:1px solid #174f99; + border-left:none; + background-color: transparent; + min-height: 34px; + padding-bottom: 5px; + padding-top: 6px; + color: #174f99 !important; + } + #masthead #site-title .searchform fieldset .btn:hover { + background-color: #174f99; + color: white !important; + } + #uc-site-title a { + letter-spacing:0.5px; + } + + +/* ================== Navbar ==================== */ + +.navbar { + margin-bottom:-1px; +} + .navbar-default .navbar-nav > li > a { + color:white; + letter-spacing: 0.5px; + } + .navbar-default .navbar-nav > li > a:hover { + color:rgba(255,255,255,0.8); + } + +/* ================== Home ==================== */ +.home .entry-content { + margin-top:0px; +} + +.home .panel-grid { + margin-bottom:0px !important; +} + +.home .hentry { + margin-bottom:0px !important; +} + +.home .home-headline { + margin-top:80px; +} + +.home .panel-grid:nth-child(1) > .siteorigin-panels-stretch { + background-position:center center !important; +} + +.home .panel-grid-cell:nth-child(1) > .widget_black-studio-tinymce{ + padding-bottom:200px !important; +} + + @media (max-width:767px) { + .home .panel-grid-cell:nth-child(1) > .widget_black-studio-tinymce{ + padding-bottom: 60px !important; + } + } + .home .panel-grid-cell .panel-grid-cell > .widget_black-studio-tinymce{ + padding-bottom:0px !important; + } + + .home .home-headline h1 { + color:white; + font-size:48px; + background-color:rgba(14,24,58,0.9); + padding:10px 20px; + text-transform:uppercase; + display:inline; + line-height:90px; + -webkit-box-decoration-break: clone; + -ms-box-decoration-break: clone; + -o-box-decoration-break: clone; + box-decoration-break: clone; + } + @media (max-width:991px){ + .home .home-headline h1 { + font-size:38px; + line-height:75px; + } + } + @media (max-width:767px){ + .home .home-headline h1 { + font-size:30px; + line-height:64px; + } + } + + .home .home-headline a { + background-color:rgba(229,0,43,0.75); + margin-top: 15px; + padding: 9px 16px; + display:inline-block; + color:white !important; + font-family: 'Roboto Slab'; + font-weight:400; + text-transform:uppercase; + text-decoration:none; + letter-spacing:1px; + + } + .home .home-headline a:hover { + background-color:rgba(229,0,43,1); + } + .home .home-headline a .glyphicon-new-window { + display:none; + } + + @media (max-width:1200px){ + .home .home-headline .col-sm-7 { + width:75%; + } + } + + @media (max-width:991px){ + .home .home-headline .col-sm-7 { + width:80%; + } + } + @media (max-width:767px){ + .home .home-headline .col-sm-7 { + width:100%; + } + } + +.home .full-width-3-grid-home .panel-grid-cell { + padding:30px 35px !important; + line-height: 1.6em; +} + .home .full-width-3-grid-home .panel-grid-cell h2 { + text-align:center; + font-size:35px; + color:white; + line-height:1.2em; + margin-bottom:25px; + } + + .home .full-width-3-grid-home .panel-grid-cell h2 a { + color:white !important; + text-decoration:none; + } + + .home .full-width-3-grid-home .panel-grid-cell p { + color:white !important; + } + + @media (min-width:1600px){ + .home .full-width-3-grid-home .panel-grid-cell { + padding-left:80px !important; + padding-right:80px !important; + } + } + + + .home .full-width-3-grid-home .panel-grid-cell:nth-child(1) { + background-color:rgba(125,136,142,0.92); + margin-bottom: -5000px; + padding-bottom: 5000px !important; + } + @media (max-width:780px) { + .home .full-width-3-grid-home .panel-grid-cell:nth-child(1) { + padding-bottom:0!important; + margin-bottom: 0!important; + } + } + + .home .full-width-3-grid-home .panel-grid-cell:nth-child(2) { + background-color:rgba(46,78,139,0.92); + margin-bottom: -5000px; + padding-bottom: 5000px !important; + } + @media (max-width:780px) { + .home .full-width-3-grid-home .panel-grid-cell:nth-child(2) { + padding-bottom:0!important; + margin-bottom: 0!important; + } + } + + .home .full-width-3-grid-home .panel-grid-cell:nth-child(3) { + background-color:rgba(206,149,46,0.9); + margin-bottom: -5000px; + padding-bottom: 5000px !important; + } + @media (max-width:780px) { + .home .full-width-3-grid-home .panel-grid-cell:nth-child(3) { + padding-bottom:0!important; + margin-bottom: 0!important; + } + } + + + .full-width-3-grid-home .widget_siteorigin-panels-postloop { + position:relative; + } + + .full-width-3-grid-home .widget_siteorigin-panels-postloop .read_more a { + display:block; + text-align:center; + color:white !important; + padding:12px 20px 10px; + text-decoration:none; + border:1px solid white; + width:50%; + margin-left: auto; + margin-right: auto; + text-transform:uppercase; + font-family: 'Roboto Slab'; + font-weight:400; + margin-top:35px; + margin-bottom:35px; + + } + @media (min-width:1500px){ + .full-width-3-grid-home .widget_siteorigin-panels-postloop .read_more a { + width:200px; + } + } + @media (min-width:781px) and (max-width:1020px) { + .full-width-3-grid-home .widget_siteorigin-panels-postloop .read_more a { + width:80%; + } + } + @media (max-width:780px) { + .full-width-3-grid-home .widget_siteorigin-panels-postloop .read_more a { + width:40%; + } + } + @media (max-width:450px) { + .full-width-3-grid-home .widget_siteorigin-panels-postloop .read_more a { + width:70%; + } + } + .full-width-3-grid-home .widget_siteorigin-panels-postloop .read_more a:hover { + background-color:white; + color:#0e183a !important; + } + +.home .panel-grid:nth-child(2) .panel-row-style { + padding-top:50px; + padding-bottom:50px; +} + +.home #content .panel-grid .widget .widget-title { + color:white; + font-size:30px; + padding-bottom: 20px; +} + +.home .full-width-3-grid-home .panel-grid-cell .entry-meta { + display:none; +} + + +.home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-date { + width:64px !important; +} + + .home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-date .uc-cal-event-month { + color:white !important; + font-size: 15px !important; + padding-top: 9px !important; + } + .home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover .uc-cal-event-date .uc-cal-event-month { + /*background-color:#081132 !important;*/ + color:white !important; + } + + .home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-date .uc-cal-event-day { + color:white !important; + font-size: 30px !important; + font-weight:700 !important; + padding-bottom: 1px !important; + margin-top: -6px !important; + } + .home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover .uc-cal-event-date .uc-cal-event-day { + /*background-color:#081132 !important;*/ + color:white!important; + } + + .home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-title { + color:#0D7EE8 !important; + font-family: 'Roboto Slab' !important; + font-weight:400 !important; + font-size:18px !important; + } + .home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover { + text-decoration:none !important; + } + .home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover .uc-cal-event-title { + color:#046AC9 !important; + text-decoration:none !important; + } + + .home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-time { + color:white !important; + padding-left: 9px !important; + } + .home #content .panel-grid .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover .uc-cal-event-time { + color:white !important; + } + + .home #content .panel-grid .widget .uc-cal .uc-cal-no-events { + color:white !important; + } + +/* ================== Interior ==================== */ + +body.page { + background-color:#F4F4F4; +} + + body.page.home { + background-color:white; + } + +#page-blank .row { + background-color:white; +} + .home #page-blank .row { + background-color:transparent; + } + +#page-blank .entry-content { + margin-top:0px; +} + +#primary #main .page .entry-header h1 { + font-size:40px; + color:#016DC8; + border-bottom:none; + padding-bottom:6px; +} + +#page-blank h3.widget-title { + font-size:22px; + color:#016DC8; +} + +#page-blank #page-sidebar { + margin-left:3px; + margin-right:3px; +} + @media (max-width:991px) { + #page-blank #page-sidebar { + width:100%; + background-color:transparent; + border:none; + padding-top:0px; + } + } +#primary #main .page h1 { + border-bottom:none; + padding-bottom:10px; + margin-top:5px; + font-size:35px; + color:#016DC8; +} + + #primary #main .page h2 { + color:#CE952E; /* Yellow color */ + } + +#primary #main .page h3.widget-title { + font-weight: 400; + margin-bottom: 15px; + margin-top: 5px; + color:#016DC8; /* Blue color */ +} + + #primary #main .page h2,#primary #main .page h3, #primary #main .page h1 + h2 { + margin-top:10px; + margin-bottom:15px + } + + #primary #main .page { + padding-bottom:2em; + } + +#page-page, #page-search, #page-single, #page-archive { + background-color:white; + border:1px solid #ededed; +} + #page-page #main, #page-search #main, #page-single #main, #page-archive #main { + border:none; + } + #page-page .col-sm-9, #page-search .col-md-9, #page-single .col-md-9, #page-archive .col-sm-9, #page-blank .col-sm-9{ + border:none; + width:73%; + } + @media (max-width:991px) { + #page-page .col-sm-9, #page-search .col-md-9, #page-single .col-md-9, #page-archive .col-sm-9, #page-blank .col-sm-9{ + width:100%; + } + } + +#page-page #page-sidebar { + +} + @media (max-width:991px) { + #page-page #page-sidebar { + width:100%; + background-color:transparent; + border:none; + margin-left:15px; + padding-top:0px; + padding-left:0px; + } + } + + + + +/* ================== Sidebar ==================== */ + +#page-sidebar { + background-color:#EAEAEA; + padding-left:0px; + padding-right:0px; + margin-left:-15px; + border:none; + padding-top:31px; + margin-right:30px; + border:1px solid #ddd; + border-top:0; +} + + @media (max-width:767px) { + #page-sidebar { + background-color:transparent !important; + padding-left:15px; + padding-right:15px; + margin-left:auto; + border:none; + margin-top:auto; + padding-top:0px; + + } + } + + + + #page-sidebar h1.widget-title { + color:#444 !important; + background-color:#EAEAEA; + } + + #page-sidebar .widget { + border:none; + background-color:transparent; + } + + #page-sidebar .widget .widget-head { + background-color:transparent; + } + #page-sidebar .widget h2.widget-title { + color:#666; + background-color:transparent; + } + + #page-sidebar .screen-reader-text { + display:none; + } + + #page-sidebar select { + margin-left: 15px; + margin-top: 10px; + } + +#page-sidebar a { + color:#0E73CD !important; +} + + +#page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-date { + width:64px !important; +} + + #page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-date .uc-cal-event-month { + color:#0d7ee8 !important; + font-size: 15px !important; + padding-top: 9px !important; + } + #page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover .uc-cal-event-date .uc-cal-event-month { + /*background-color:#081132 !important;*/ + color:#0d7ee8 !important; + } + + #page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-date .uc-cal-event-day { + color:#333 !important; + font-size: 30px !important; + font-weight:400 !important; + padding-bottom: 1px !important; + margin-top: -6px !important; + } + #page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover .uc-cal-event-date .uc-cal-event-day { + /*background-color:#081132 !important;*/ + color:#333!important; + } + + #page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-title { + color:#0D7EE8 !important; + font-family: 'Roboto Slab' !important; + font-weight:400 !important; + font-size:15px !important; + } + #page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover { + text-decoration:none !important; + } + #page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover .uc-cal-event-title { + color:#046AC9 !important; + text-decoration:none !important; + } + + #page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event .uc-cal-event-time { + color:#333 !important; + padding-left: 9px !important; + } + #page-sidebar .widget .uc-cal.uc-iconcal .uc-cal-list .uc-cal-item .uc-cal-event:hover .uc-cal-event-time { + color:#333 !important; + } + + #page-sidebar .widget .uc-cal .uc-cal-no-events { + color:#333 !important; + } + + +/* ==================Archive ==================== */ + +@media (min-width:767px) and (max-width:991px) { + #page-archive .col-md-3{ + background-color:transparent !important; + + padding-left:15px; + padding-right:15px; + margin-left:auto; + border:none; + margin-top:auto; + } +} + +#page-archive .entry-header h1.page-title { + border-bottom: 1px solid #eee; + color: #ce952e; /* yellow color */ + font-size: 22px; + margin-bottom: 0; + margin-top: 39px; + padding-bottom: 15px; +} + #page-archive .entry-header h1.page-title:before { + content: "Posts in: "; + color:#333; + font-size:16px; + } + + +/* ================== Search ==================== */ + +body.search .no-results.not-found .page-header { + display:none !important; +} + +#page-search .col-md-9 { + margin-top:42px; +} + + #page-search .col-md-9 h1.page-title { + margin-top:0px; + margin-bottom:40px; + color:#333; + font-size:16px; + border-bottom: 1px solid #eee; + padding-bottom: 15px; + } + #page-search .col-md-9 h1.page-title span { + color:#CE952E; /* Yellow color */ + font-size:22px; + } + +/* ================== Single ==================== */ +# + + +#page-single h1.entry-title { + margin-bottom:20px; +} + +/* ================== Footer ==================== */ + +#footers { + border-color:#333134; + background-color:#1C1D21; + color:white; +} + #mega-footer { + padding-top:2em; + } + #footers #mega-footer .widget .widget-title { + color:white; + font-size:24px !important; + } + + #footers #mega-footer p { + color:white; + line-height:1em; + } + + #footers #mega-footer .uc-label.uc-label-email { + width: 50px; + } + + #footers #mega-footer td, #footers #mega-footer th { + border:none !important; + padding:0 0 8px; + color:white; + } + + #mega-footer .widget.uc-contact-widget .table-responsive { + margin-bottom: 0; + padding: 1em 1em 0; + } + + #footers #mega-footer .widget a { + color:#0E73CD !important; + } + #mega-footer .widget .uc-cal .uc-cal-item { + margin-bottom:0.5em !important; + margin-top:0em!important; + } + #mega-footer .widget .uc-cal .uc-cal-item:nth-child(1) { + margin-top:1em !important; + } + + #mega-footer .widget .uc-cal .uc-cal-item .uc-cal-event .uc-cal-event-date { + color:white !important; + } + #mega-footer .widget .uc-cal .uc-cal-item .uc-cal-event:hover .uc-cal-event-date { + color:white !important; + } + + #mega-footer .widget .uc-cal .uc-cal-no-events { + margin-left:-50px !important + } + + #footer { + padding-top:0.5em; + padding-bottom:1em; + text-align:center; + } + @media (max-width:767px) { + #footer { + line-height:1.6em; + } + } + + +/* ================== Custom Accordion ==================== */ +/*----- Accordion -----*/ +.accordion, .accordion * { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; +} + +.accordion { + overflow:hidden; + position:relative; +} + +/*----- Section Titles -----*/ +.accordion-section-title { + width:100%; + display:inline-block; + transition:all linear 0.15s; + font-size:1.200em; + color:#fff; +} + +.accordion-section:last-child .accordion-section-title { + border-bottom:none; +} + + +.accordion .accordion-section-title img:hover { + cursor:pointer; +} + +.accordion-section-title.caption-text { + color:white; + position:absolute; + left:0; + bottom:0; + font-family: 'Roboto Slab'; + font-weight:400; + text-transform:uppercase; + text-decoration:none; + letter-spacing:1px; + padding: 5px 10px; + line-height:1.2em; + background-color:rgba(0,15,48,0.8); +} + + .accordion-section-title.caption-text.active { + background-color:rgba(229,0,43,0.8); + } + .accordion-section-title.caption-text.active:hover { + background-color:rgba(229,0,43,0.8); + } + + .accordion-section-title.caption-text:hover { + background-color:rgba(0,15,48,1); + } + .accordion-section-title.active, .accordion-section-title:hover { + text-decoration:none; + } + +/*----- Section Content -----*/ +.accordion-section-content { + padding:30px; + display:none; + border: 1px solid #e3e3e3; + background:#f7f7f7; + background-color: whitesmoke; + margin-bottom:30px; +} + + .accordion-section-content h1 { + margin-top:0px; + } + + + + + + \ No newline at end of file diff --git a/template-class.php b/template-class.php new file mode 100644 index 0000000..fbb3a28 --- /dev/null +++ b/template-class.php @@ -0,0 +1,221 @@ +templates = array(); + $this->plugin_locale = 'pte'; + + // Grab the translations for the plugin + add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); + + // Add a filter to the page attributes metabox to inject our template into the page template cache. + add_filter('page_attributes_dropdown_pages_args', array( $this, 'register_project_templates' ) ); + + // Add a filter to the save post in order to inject out template into the page cache + add_filter('wp_insert_post_data', array( $this, 'register_project_templates' ) ); + + // Add a filter to the template include in order to determine if the page has our template assigned and return it's path + add_filter('template_include', array( $this, 'view_project_template') ); + + // Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively. + register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) ); + + // Add your templates to this array. + $this->templates = array( + 'page-sample.php' => __( 'Sample', $this->plugin_slug ), + + //'page-sample3.php' => __( 'Sample3', $this->plugin_slug ), + ); + + // adding support for theme templates to be merged and shown in dropdown + $templates = wp_get_theme()->get_page_templates(); + $templates = array_merge( $templates, $this->templates ); + + } // end constructor + + /** + * Load the plugin text domain for translation. + * + * @since 1.0.0 + */ + public function load_plugin_textdomain() { + + $domain = $this->plugin_slug; + $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); + + load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' ); + load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' ); + + } // end load_plugin_textdomain + + /** + * Adds our template to the pages cache in order to trick WordPress + * into thinking the template file exists where it doens't really exist. + * + * @param array $atts The attributes for the page attributes dropdown + * @return array $atts The attributes for the page attributes dropdown + * @verison 1.0.0 + * @since 1.0.0 + */ + public function register_project_templates( $atts ) { + + // Create the key used for the themes cache + $cache_key = 'page_templates-' . md5( get_theme_root() . '/' . get_stylesheet() ); + + // Retrieve the cache list. If it doesn't exist, or it's empty prepare an array + $templates = wp_cache_get( $cache_key, 'themes' ); + if ( empty( $templates ) ) { + $templates = array(); + } // end if + + // Since we've updated the cache, we need to delete the old cache + wp_cache_delete( $cache_key , 'themes'); + + // Now add our template to the list of templates by merging our templates + // with the existing templates array from the cache. + $templates = array_merge( $templates, $this->templates ); + + // Add the modified cache to allow WordPress to pick it up for listing + // available templates + wp_cache_add( $cache_key, $templates, 'themes', 1800 ); + + return $atts; + + } // end register_project_templates + + /** + * Checks if the template is assigned to the page + * + * @version 1.0.0 + * @since 1.0.0 + */ + public function view_project_template( $template ) { + + global $post; + + // If no posts found, return to + // avoid "Trying to get property of non-object" error + if ( !isset( $post ) ) return $template; + + if ( ! isset( $this->templates[ get_post_meta( $post->ID, '_wp_page_template', true ) ] ) ) { + return $template; + } // end if + + $file = plugin_dir_path( __FILE__ ) . 'templates/' . get_post_meta( $post->ID, '_wp_page_template', true ); + + // Just to be safe, we check if the file exist first + if( file_exists( $file ) ) { + return $file; + } // end if + + return $template; + + } // end view_project_template + + /*--------------------------------------------* + * deactivate the plugin + *---------------------------------------------*/ + static function deactivate( $network_wide ) { + foreach($this as $value) { + page-template-example::delete_template( $value ); + } + + } // end deactivate + + /*--------------------------------------------* + * Delete Templates from Theme + *---------------------------------------------*/ + public function delete_template( $filename ){ + $theme_path = get_template_directory(); + $template_path = $theme_path . '/' . $filename; + if( file_exists( $template_path ) ) { + unlink( $template_path ); + } + + // we should probably delete the old cache + wp_cache_delete( $cache_key , 'themes'); + } + + /** + * Retrieves and returns the slug of this plugin. This function should be called on an instance + * of the plugin outside of this class. + * + * @return string The plugin's slug used in the locale. + * @version 1.0.0 + * @since 1.0.0 + */ + public function get_locale() { + return $this->plugin_slug; + } // end get_locale + +} // end class