Example #1
0
  public function manage() { 

		global $wf, $blog_id;
		
    $this->setup_view( array(
        "title_args" => array( "text" => sprintf( __("Masterplan - <small>Powered by %s</small>", MASTERPRESS_DOMAIN), '<a href="http://masterpressplugin.com" target="_blank">MasterPress</a>' ) )
      )
    );

    if (defined("MASTERPRESS_LEGACY_DIR_MIGRATE")) {
      
  		if (defined("MASTERPRESS_LEGACY_DIR") && MasterPress::$action != "legacy_dir_migrate") {
			
  			update_option("mp_legacy_dir", "1");
			
  			$ud = wp_upload_dir(); 

  			$steps  = WOOF_HTML::open("ul");
			
  			$new_ul_base = str_replace($wf->site->url, "", $ud["baseurl"]) . "/mp/files/$1";
			
  			$rules = <<<HTML
		
  			&lt;IfModule mod_rewrite.c&gt;<br>

  			RewriteEngine On<br>
  			RewriteBase /<br>
  			<br>
  			RewriteCond %{REQUEST_FILENAME} !-f<br>
  			RewriteRule ^wp-content/mp/uploads/(.+) $new_ul_base [PT]<br>
  			<br>
  			RewriteCond %{REQUEST_FILENAME} !-f<br>
  			RewriteRule ^wp-content/blogs.dir/([0-9]+)/mp/uploads/(.+) wp-content/blogs.dir/$1/mp/files/$2 [PT]<br>
  			<br>
  			RewriteCond %{REQUEST_FILENAME} !-f<br>
  			RewriteRule ^wp-content/mp/(.+) wp-content/uploads/mp/$1 [PT,L]<br>
  			&lt;/IfModule&gt;	
			
HTML;
	
  			$step = 1;
			
  			$steps .= WOOF_HTML::tag("li", "", __("<b>".$step++.".</b> Backup your WordPress database."), MASTERPRESS_DOMAIN );
			
  			$steps .= WOOF_HTML::tag("li", "", sprintf( __("<b>(Optional)</b>. To avoid 404s from existing links to your files, you may wish to place the following lines just above in your .htaccess file (at the root of your site).<code>%s</code><br><b>IMPORTANT:</b> These rules should be <b>placed just above the line # BEGIN WordPress </b> in your .htaccess file, as placing it above rules from caching plugins may cause issues.", MASTERPRESS_DOMAIN ), $rules ) );
			
  			if (MASTERPRESS_MULTI) {

  				if (WOOF_MS_FILES) {

  					if (is_main_site()) {
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Move the masterpress content folder currently at:<br> <span class="tt">%s/mp</span><br>to:<br> <span class="tt">%s/mp</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, $ud["basedir"] ) );
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, WP_CONTENT_DIR  ) );
  					}
				
  					$base = WP_CONTENT_DIR . WOOF_DIR_SEP . "blogs.dir" . WOOF_DIR_SEP . $blog_id;
  					$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $base , $base  ) );
  					$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); 

  				} else {
				
  					if (is_main_site()) {

  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Move the masterpress content folder currently at:<br> <span class="tt">%s/mp</span><br>to:<br> <span class="tt">%s/mp</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, $ud["basedir"] ) );
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $ud["basedir"], $ud["basedir"]  ) );
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); 

  					} else {
					
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $ud["basedir"], $ud["basedir"]  ) );
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); 
				
  					}
				
  				}
				
  			} else {
				
  				$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Move the masterpress content folder currently at:<br> <span class="tt">%s/mp</span><br>to:<br> <span class="tt">%s/mp</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, $ud["basedir"] ) );
  				$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $ud["basedir"], $ud["basedir"]  ) );
  				$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); 
			
  			}
			
  			$steps .= WOOF_HTML::close("ul");
			
  			MPV::warn( sprintf( __('Your MasterPress installation is storing certain content in folders which are <a href="%s">no longer the default locations in version 1.0.1.</a><br><br>To migrate to the new location: %s', MASTERPRESS_DOMAIN ), "http://masterpressplugin.com/blog/content-in-101/", $steps ) );
			
  		} else if (get_option("mp_legacy_dir")) {
			
  			$migrate = sprintf( __('Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ); 

  			MPV::warn( sprintf( __('It appears you\'ve moved your MasterPress content folder from the old <span class="tt">wp-content/mp</span> location without running the necessary database migration.<br><br>%s', MASTERPRESS_DOMAIN ), $migrate ) );
			
  		}
		
		}
    
    if (isset($_POST["import_masterplan"]) || isset($_POST["restore_masterplan"])) {
      self::import();
    } 

  }
Example #2
0
  public function init() {
    
    global $wf;
    
    // check if we're in a child theme
    
    $template_dir = get_template_directory();
    $stylesheet_dir = get_stylesheet_directory();
    
    
    // check if there are any templates that have the same name, which can cause confusion

    $names = array(); 
    $dupes = array();
    
    self::get_names($template_dir, $names, $dupes);
    
    if ($stylesheet_dir != $template_dir) {
      self::get_names($stylesheet_dir, $names, $dupes);
    }
    
    
    if (count($dupes)) {
      
      $msg  = WOOF_HTML::tag("p", array(), __("<strong>Warning:</strong> your theme appears to contain multiple template files with the same <b>Template Name</b>.<br />This may cause some templates to become invisible to both WordPress and MasterPress.<br />Please verify the following, and make changes to your template files as necessary:", MASTERPRESS_DOMAIN)); 
      $msg .= WOOF_HTML::open("ul");
      
      foreach ($dupes as $template_name => $file_name) {
        $msg .= WOOF_HTML::tag("li", array(), sprintf( __('<span class="tt">%s</span> is called <b>%s</b>, which is already used by <span class="tt">%s</span>', MASTEPRESS_DOMAIN), $file_name, $template_name, $names[$template_name]) );
      }
         
      $msg .= WOOF_HTML::close("ul");

      MPV::warn($msg);
      
    }
  
    $action = MasterPress::$action;
    
    // inform the view what to render in the info panel
    MasterPress::$view->is_template_set = true;

    
    
    if ($action == "edit-field" || $action == "create-field") {
      // inform the view what to render in the info panel
      MasterPress::$view->parent = MPM_FieldSet::find_by_id(MasterPress::$parent);

      // enqueue the field type CSS
      $type = MasterPress::$model->type;
      
      MPFT::options_admin_head($type);

      // enqueue dependent scripts for all field types (could improve this in the future)
      foreach (MPFT::type_keys() as $type) {
        if ($ftc = MPFT::type_class($type)) {
          call_user_func( array($ftc, "enqueue") );
        }
      }


    }

    if ($action == "create-field") {
      MasterPress::$model->field_set_id = MasterPress::$parent;
      MasterPress::$model->infer_position();
    }

  }
Example #3
0
  public static function create_directories() {
    
    MPU::incl("view/mpv.php");

    global $wf;
    global $blog_id;
    
    $main_exists = true;
    $global_exists = true;
		$try_content = true;
		

    self::$is_masterplan = ( isset($_GET["page"] ) && $_GET["page"] == "masterpress" );
    
    
    if (!file_exists(MASTERPRESS_CONTENT_DIR)) {
      
			if ($try_content) {

	      // if the base uploads directory doesn't exist, try to create it
	      if (!wp_mkdir_p(MASTERPRESS_CONTENT_DIR)) {
	        $main_exists = FALSE;
			
					// check that the base blogs.dir actually exists!
					$bd_base_dir = WP_CONTENT_DIR.WOOF_DIR_SEP."blogs.dir";
				
	        if (is_multisite()) {
	  				MPV::warn(sprintf(__('<strong>Note: the MasterPress content folder %s for this site does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved.', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'</span>', '<span class="tt">wp-content/blogs.dir/'.$blog_id.'/</span>', self::dir_cmd(WP_CONTENT_DIR.WOOF_DIR_SEP."blogs.dir".WOOF_DIR_SEP.$blog_id.WOOF_DIR_SEP), '"'.MPU::current_url().'"')); 
	        } else {
	          MPV::warn(sprintf(__('<strong>Note: the MasterPress content folder %s does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder the permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved.', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'</span>', '<span class="tt">wp-content</span>', self::dir_cmd(WP_CONTENT_DIR), '"'.MPU::current_url().'"')); 
	        }
      
	        update_site_option("mp_dir_problem", true);
        
	      } else {
        
	        chmod(MASTERPRESS_CONTENT_DIR, 0755);
        
	      }

			}
		
    }
    
    
    if (!file_exists(MASTERPRESS_GLOBAL_CONTENT_DIR)) {
      // if the global content directory doesn't exist, try to create it
      if (MASTERPRESS_GLOBAL_CONTENT_DIR != MASTERPRESS_CONTENT_DIR) {
        
        if (!wp_mkdir_p(MASTERPRESS_GLOBAL_CONTENT_DIR)) {
          $global_exists = FALSE;
          MPV::warn(sprintf(__('<strong>Note: the MasterPress shared content folder %s for your multi-site network does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder the permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_GLOBAL_CONTENT_DIR.'</span>', '<span class="tt">wp-content</span>', self::dir_cmd(WP_CONTENT_DIR), '"'.MPU::current_url().'"')); 

          update_site_option("mp_dir_problem", true);
        
        } else {
        
          chmod(MASTERPRESS_GLOBAL_CONTENT_DIR, 0755);

        }
        
      } 
      
    } 

    $warning_777 = __('Please change the permissions of your <span class="tt">wp-content</span> directory to <span class="tt">755</span>. <br />');

    $stop_trying_global = false;
    $stop_trying = false;

    
    if ($main_exists && $global_exists) {
      
      $stop_trying = false;
      $stop_trying_global = false;
      
      // test if the standard sub-directories exist
      
      $not_writable_warning = sprintf(__('<strong>Note: the MasterPress folder %s does not seem to be writable</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give this folder the permission 777.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'.</span>', self::chmod_cmd(MASTERPRESS_CONTENT_DIR), '"'.MPU::current_url().'"');
      
      if (is_multisite()) {
        $not_writable_global_warning = sprintf(__('<strong>Note: the MasterPress shared folder %s for your multi-site network does not seem to be writable</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give this folder the permission 777.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_GLOBAL_CONTENT_DIR.'</span>', self::chmod_cmd(MASTERPRESS_GLOBAL_CONTENT_DIR), '"'.MPU::current_url().'"');
      } else {
        $not_writable_global_warning = $not_writable_warning;
      }
      
      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_IMAGE_CACHE_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_IMAGE_CACHE_DIR)) {
            $stop_trying = TRUE;
            MPV::warn($not_writable_warning); 
          }
        }
        
      }
      
      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR)) {
            $stop_trying = TRUE;
          MPV::warn($not_writable_warning); 
          }
        }
        
      }

      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_FILE_FROM_URL_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_FILE_FROM_URL_DIR)) {
            $stop_trying = TRUE;
          MPV::warn($not_writable_warning); 
          }
        }
        
      }

      
      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_UPLOADS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_UPLOADS_DIR)) {
          $stop_trying = TRUE;
          MPV::warn($not_writable_warning); 
          } 
        }
        
      }      
      
      if (!is_multisite() && $stop_trying) {
        // global and site are the same path
        $stop_trying_global = true;
      }
      

      if (!$stop_trying_global) {
            
        if (!file_exists(MASTERPRESS_CONTENT_MENU_ICONS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_MENU_ICONS_DIR)) {
            $stop_trying_global = true;
            MPV::warn($not_writable_global_warning); 
          
          }
        } 
      
      }
      
      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_global_warning); 
          }
        }
        
      }

      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_CONTENT_MPFT_CACHE_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_MPFT_CACHE_DIR)) {
            $stop_trying_global = TRUE;
            MPV::warn($not_writable_global_warning); 
          }
        }
        
      }
      
      
      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_TMP_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_TMP_DIR)) {
            $stop_trying_global = TRUE;
            MPV::warn($not_writable_warning); 
          }
        }
        
      }


      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_EXTENSIONS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_global_warning); 
          }
        }
        
      }

      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_extensions_warning); 
          }
        }
        
      }

      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_EXTENSIONS_ICONS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_ICONS_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_extensions_warning); 
          }
        }
        
      }
  
      
      if (!$stop_trying) {

        // check the writable status of MasterPress directories

        $not_writables = self::check_writable( array(
          MASTERPRESS_CONTENT_MENU_ICONS_DIR, 
          MASTERPRESS_CONTENT_IMAGE_CACHE_DIR, 
          MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR, 
          MASTERPRESS_CONTENT_FILE_FROM_URL_DIR, 
          MASTERPRESS_CONTENT_MPFT_CACHE_DIR, 
          MASTERPRESS_TMP_DIR, 
          MASTERPRESS_CONTENT_MASTERPLANS_DIR, 
          MASTERPRESS_EXTENSIONS_DIR, 
          MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR, 
          MASTERPRESS_EXTENSIONS_ICONS_DIR, 
          MASTERPRESS_CONTENT_UPLOADS_DIR
        ));
        
        if (count($not_writables)) {
          $content_paths = WOOF_HTML::open("p");
          $chmods = WOOF_HTML::open("code");
          
          foreach ($not_writables as $nw) {
            $content_paths .= WOOF_HTML::tag("span", "class=tt", $nw["content_path"]."<br />");
            $chmods .= $nw["chmod"];
          }

          $content_paths .= WOOF_HTML::close("p");
          $chmods .= WOOF_HTML::close("code");

          MPV::warn(sprintf(__('<p><strong>Note:</strong> these MasterPress folders in <span class="tt">wp-content</span> are not writable which will cause problems using WordPress:%s<br /></p><p>Using your FTP client, server admin panel, or operating system (for local installations), please give these folders permission 777.<br /><br />Alternatively, use the following commands if you have shell or terminal access:<br />%s', MASTERPRESS_DOMAIN), $content_paths, $chmods)); 

        } 
      

        
      }
      
      
    }

		


    
    
  }